Re: freebcp out from MS SQL Server drops spaces [NC]

Cedric ROUVRAIS <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <OF54BEDACE.8FD6B12D-ON852575EE.004FCD00-852575EE.00502EAF@us.world.socgen>
Hi,

Sent the source code to you and James.

In a nutshell, at the end of bcp::_bcp_exec_out inserted two segments:

                              /**
                               * Per ANSI Spec for fixed width character
columns, pad with spaces
                               * It would be more efficient to not trim the
data provided by the database, but that
                               * requires more extensive code change above.
                               */
                              if ((curcol->column_type == SYBCHAR) &&
(buflen < curcol->column_size)) {
                                    int pad;
                                    for (pad = buflen; pad <
curcol->column_size; pad++) {
                                          written = fwrite(" ", 1, 1,
hostfile);
                                          if (written < 1) {
                                                dbperror(dbproc, SYBEBCWE,
errno);
                                                return FAIL;
                                          }
                                    }
                              }

and

                  /** Output some progres information like Sybase BCP does
*/
                  if (rows_written % 1000 == 0) {
                        printf("%d rows successfully bulk-copied to
host-file.\n", rows_written);
                  }


In the freebcp.c source code added : after t: to make it an optional
argument option.

      while ((ch = getopt(argc, argv,
"m:f:e:F:L:b:t::r:U:P:I:S:h:T:A:O:0:ncEdvV")) != -1) {

Changed the case processing segment to

            case 't':
                  pdata->tflag++;
                  if (optarg == NULL) {
                        pdata->fieldterm = '\0';
                        pdata->fieldtermlen = 0;
                  } else {
                        pdata->fieldterm = strdup(optarg);
                        pdata->fieldtermlen = unescape(pdata->fieldterm);
                  }
                  break;

And replaced
            if (!pdata->tflag || !pdata->fieldterm) {  /* field terminator
not specified */
With
            if (!pdata->tflag) {     /* field terminator not specified */

a++ Cedric



|------------------------------                                            
|            Frediano Ziglio                                               
|            <[email protected]                                             
|            om>                                                           
|            Sent by:                                                      
|            freetds-bounces@l                                             
|            ists.ibiblio.org                                              
|                                                                          
|                                                                          
|            07/09/2009 09:26                                              
|            AM                                                            
|                                                                          
|                                                                          
|            Please respond to                                             
|                 FreeTDS                                                  
|            Development Group                                             
|            <[email protected]                                             
|               iblio.org>                                                 
|                                                                          
|                                                                          
                                                                           
                                                                           
                                                                        To 
                                               FreeTDS Development Group   
                                               <[email protected]> 
                                                                        cc 
                                                                           
                                                                   Subject 
                                               Re: [freetds] freebcp out   
                                               from MS SQL Server drops    
                                               spaces [NC]                 
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           




2009/7/9 Cedric ROUVRAIS <[email protected]>:
> Hi Frediano,
>
> I am not a vendor, just a simple first time user.
>
> a++ Cedric
>
>

I know, but you reported a misbehavior between FreeTDS and Microsoft
application

freddy77
_______________________________________________
FreeTDS mailing list
[email protected]
http://lists.ibiblio.org/mailman/listinfo/freetds



*************************************************************************
This message and any attachments (the "message") are confidential, intended 
solely for the addressee(s), and may contain legally privileged information.  
Any unauthorised use or dissemination is prohibited.  E-mails are susceptible 
to alteration.  Neither SOCIETE GENERALE nor any of its subsidiaries or 
affiliates shall be liable for the message if altered, changed or falsified.
*************************************************************************
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.