Re: Problem with freebcp and fixed text output [NC]

Cedric ROUVRAIS <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <OF2B3A2975.ACC9DD5A-ON8525760A.00788DA4-8525760A.0078C3FD@us.world.socgen>
Well, not in sybase for sure. This is an app that is running in production
on Sybase and that we are moving to SQL Server.

So I modified bcp.c as follows:

      /** Cedric: support for none mapped columns, Sybase style. */
      if (whichcol == TAB_COLNUM) {
                  ci->tab_colnum = 0;
                  whichcol = NO_MORE_COLS;
      }
      /** /Cedric */
      if (whichcol == NO_MORE_COLS)
            return (TRUE);
      else
            return (FALSE);

And tada it works for :o)

a++ Cedric



|------------------------------                                            
|            Konrad J Hambrick                                             
|            <[email protected]                                             
|            om>                                                           
|            Sent by:                                                      
|            freetds-bounces@l                                             
|            ists.ibiblio.org                                              
|                                                                          
|                                                                          
|            08/06/2009 05:53                                              
|            PM                                                            
|                                                                          
|                                                                          
|            Please respond to                                             
|            [email protected]                                             
|            m; Please respond                                             
|                   to                                                     
|                 FreeTDS                                                  
|            Development Group                                             
|            <[email protected]                                             
|               iblio.org>                                                 
|                                                                          
|                                                                          
                                                                           
                                                                           
                                                                        To 
                                               FreeTDS Development Group   
                                               <[email protected]> 
                                                                        cc 
                                                                           
                                                                   Subject 
                                               Re: [freetds] Problem with  
                                               freebcp and fixed text      
                                               output [NC]                 
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           





Hmmm ...

Does the FORMAT file not need an explicit 0 (zero)
in Column 6 of the 2nd row of the FORMAT file to
skip DB Table Column 2 ?

I believe this is so in MS SQLServer.

-- kjh


Cedric ROUVRAIS wrote:
> Hi,
>
> Say you have a file with 100 columns and a table with 10 colums (case for
> one of our apps), how do you selectively bcp in the file? With Sybase you
> simply do not specify TAB_COLNUM and that column in the file is ignored.
>
> Sample format file (incomplete)
>
> 10.0
> 182
> 1 SYBCHAR 0 20 ";" 1 id
> 2 SYBCHAR 0 20 ";"
> 3 SYBCHAR 0 20 ";" 2 gop
>
> freebcp chokes on the second column (2 SYBCHAR 0 20 ";") and exits
whereas
> Sybase knows that it just needs to ignore this data, so I am modifying
> bcp.c to accomodate this behaviour.
>
> If I understand what you mean
>
> 2 SYBCHAR 0 20 ";" 0
>
> would be the appropriate format file and then freebcp would ignore this
> field but still bcp the file in?
>
> a++ Cedric
>
>
>
> |------------------------------

> |            "James K. Lowden"

> |            <jklowden@freetds

> |            .org>

> |            Sent by:

> |            freetds-bounces@l

> |            ists.ibiblio.org

> |

> |

> |            08/06/2009 05:39

> |            PM

> |

> |

> |            Please respond to

> |                 FreeTDS

> |            Development Group

> |            <[email protected]

> |               iblio.org>

> |

> |

>

>

>
To
>                                                FreeTDS Development Group

>
<[email protected]>
>
cc
>

>
Subject
>                                                Re: [freetds] Problem with

>                                                freebcp and fixed text

>                                                output [NC]

>

>

>

>

>

>

>
>
>
>
> Cedric ROUVRAIS wrote:
>> The issue one of my teams reported is that if there is a column in the
>> file that does not get imported into the table, then it fails. The
>> faulty procedure is _bcp_readfmt_colinfo which fails because TAB_COLNUM
>> is not present in that case.
>>
>> Any ideas before I start implementing a fix?
>
> I don't know what you mean by "not present", Cedric.  It's an integer; it
> has to be present.
>
> It looks OK to me.  The dbproc->hostfileinfo->host_columns array points
to
> a memory allocated with calloc(3) in bcp_columns().  By default, then,
> ci->tab_colnum should be zero, meaning the field in the file is ignored.
>
> HTH.
>
> --jkl
> _______________________________________________
> 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.
> *************************************************************************
>
> _______________________________________________
> FreeTDS mailing list
> [email protected]
> http://lists.ibiblio.org/mailman/listinfo/freetds
>
_______________________________________________
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.