Skip to Content.
Sympa Menu

freetds - RE: [freetds] possible bug: bcp_bind seems to be broken when usin g variables assignment

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Thompson, Bill D (London)" <ThompBil AT exchange.uk.ml.com>
  • To: "'freetds AT lists.ibiblio.org'" <freetds AT lists.ibiblio.org>
  • Subject: RE: [freetds] possible bug: bcp_bind seems to be broken when usin g variables assignment
  • Date: Thu, 30 Jan 2003 09:22:44 -0000

Anwar,

My guess is that you have not defined a dblib error message handler before
calling bcp_init, and there is something wrong with accessing the table you
have specified in the bcp_init() call.
If your code fragment is not cut down, neither have you trapped any possible
error return from bcp_init()

if this is the case, try coding message handlers, viz:

in the main code:

after calling dbinit():

dberrhandle(err_handler);
dbmsghandle(msg_handler);

with those functions defined as something like:

int err_handler(dbproc, severity, dberr, oserr, dberrstr, oserrstr)
DBPROCESS *dbproc;
int severity;
int dberr;
int oserr;
char *dberrstr;
char *oserrstr;
{

if (dberr)
{
fprintf(stderr,"Msg %ld, Level %d\n", dberr, severity);
fprintf(stderr,"%s\n\n", dberrstr);
}

else
{
fprintf(stderr,"DB-LIBRARY error:\n\t");
fprintf(stderr,"%s\n", dberrstr);
}

return(INT_CANCEL);
}

HTH,


Bill

> -----Original Message-----
> From: Anwar, Mohammed [SMTP:mohammed.anwar AT intel.com]
> Sent: 30 January 2003 06:13
> To: freetds AT lists.ibiblio.org
> Subject: [freetds] possible bug: bcp_bind seems to be broken when
> using variables assignment
>
> Hi,
> When using bcp_init followed by bcp_bind the bcp_bind will always
> fail (for me anyway, and I have tried a number of variations on the
> parameters to bcp_bind).
>
> Once I looked at the code I realized why the bind was failing.
>
> I looked at the source in bcp.c and it seems bcp_bind has a check
> for :
> if (table_column > dbproc->host_colcount)
> return FAIL;
>
>
> which will always be return FAIL as the dbproc->host_colcount
> variable is set to 0 in the bcp_init when calling :
> _bcp_clear_storage(dbproc);
>
> it seems this variable is only updated when the input file is
> provided and a call is made to
> bcp_columns
>
> the bcp_init function only updates the dbproc->bcp_colcount
> variable.
>
> I am tried examples from varoius sites but they all seem to be the
> similar, here is the link for one of them
>
>
> http://manuals.sybase.com/onlinebooks/group-cn/cng1250e/dblib/@Generic__Bo
> okTextView/47490;hf=0#X
>
> I have tried the following to see if I could get it to work:
> bcp_init(dbproc, "test_bcp..sig",NULL, NULL, DB_IN)
> bcp_columns(dbproc, 1);
> as it states bcp_columns can only be used if the input file is not
> NULL.
>
> bcp_init(dbproc, "test_bcp..sig",NULL, NULL, DB_IN)
> bcp_collen(dbproc, -1, 1);
> this fails as the host_colcount variable is 0 and the the column id
> is 1.
>
> I would really appreciate some help on this.
>
> Thanks a lot for your help..
> Anwar
>
> _______________________________________________
> FreeTDS mailing list
> FreeTDS AT lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds





Archive powered by MHonArc 2.6.24.

Top of Page