freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
Re: [freetds] bcp_done always returns error if no data was inserted
- From: Angelo Coccimiglio <ACoccimiglio AT OLG.CA>
- To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
- Subject: Re: [freetds] bcp_done always returns error if no data was inserted
- Date: Fri, 5 Dec 2014 08:37:46 -0500
Further investigation I found an example in the distribution of FreeTDS
that shows the way to handle no records being bcp'd
Before calling bcp_done you determine if any rows were processed if none
do not execute the bcp_done command
Forgot to mention that we are using SYBASE.and it does work with no
records being processed..
I will look into version 0.92
Thanks
Example Found: $1$DGA1802:[FREETDS-0_91.SRC.APPS]DATACOPY.C
if (rows_read) {
gettimeofday(&batch_start, 0);
ret = bcp_done(dbdest);
gettimeofday(&batch_end, 0);
elapsed_batch = elapsed_batch +
((double) (batch_end.tv_sec - batch_start.tv_sec)
+
((double) (batch_end.tv_usec -
batch_start.tv_usec) / 1000000.00)
);
if (ret == -1) {
fprintf(stderr, "bcp_done failed. \n");
return FALSE;
} else {
rows_done += ret;
}
}
Angelo Coccimiglio
From: "Craig A. Berry" <craigberry AT mac.com>
To: FreeTDS Development Group <freetds AT lists.ibiblio.org>,
Date: 12/05/2014 04:17 AM
Subject: Re: [freetds] bcp_done always returns error if no data was
inserted
Sent by: "FreeTDS" <freetds-bounces AT lists.ibiblio.org>
> On Dec 3, 2014, at 10:30 AM, Angelo Coccimiglio <ACoccimiglio AT OLG.CA>
wrote:
>
> Hello,
>
> I'm new to freetds... running version FREETDS-0_91
Try 0.92 and see if there's any difference.
> Whenever an attempt to bcp data within a C program and there are no
> records
> the bcp_done routine returns -1 indicating an error... If there are
> records
> available to bcp works fine..
I haven't been able to find any documentation indicating what bcp_done
should do if there are no records. There's quite likely an oversight for
that case in the FreeTDS library but if there's any chance you could try
your code with a Microsoft or Sybase library and confirm it works there
that would help. Or post a small reproducer.
>
> Is there anything I should be looking for or setting up..
> Here is part of the log wher bcp_done is called
>
>
1$DGA1808:[TSG.ACOCCIMIGLIO.VMS_1.FREETDS-0_91.SRC.TDS]UTIL.C;1:156:Changed
> query state from PENDING to DEAD
>
$1$DGA1808:[TSG.ACOCCIMIGLIO.VMS_1.FREETDS-0_91.SRC.DBLIB]DBLIB.C;46:326:dblib_release_tds_ctx(1)
>
$1$DGA1808:[TSG.ACOCCIMIGLIO.VMS_1.FREETDS-0_91.SRC.DBLIB]DBLIB.C;46:6321:dbfreebuf(5DD490)
>
$1$DGA1808:[TSG.ACOCCIMIGLIO.VMS_1.FREETDS-0_91.SRC.DBLIB]DBLIB.C;46:4984:dberrhandle(0)
>
$1$DGA1808:[TSG.ACOCCIMIGLIO.VMS_1.FREETDS-0_91.SRC.DBLIB]DBLIB.C;46:4984:dberrhandle(0)
>
$1$DGA1808:[TSG.ACOCCIMIGLIO.VMS_1.FREETDS-0_91.SRC.DBLIB]DBLIB.C;46:5003:dbmsghandle(0)
>
$1$DGA1808:[TSG.ACOCCIMIGLIO.VMS_1.FREETDS-0_91.SRC.DBLIB]DBLIB.C;46:5003:dbmsghandle(180298)
>
$1$DGA1808:[TSG.ACOCCIMIGLIO.VMS_1.FREETDS-0_91.SRC.DBLIB]DBLIB.C;46:1689:dbresults(5B9F40)
>
$1$DGA1808:[TSG.ACOCCIMIGLIO.VMS_1.FREETDS-0_91.SRC.DBLIB]DBLIB.C;46:1695:dbresults:
> dbresults_state is 3 (_DB_RES_NEXT_RESULT)
>
$1$DGA1808:[TSG.ACOCCIMIGLIO.VMS_1.FREETDS-0_91.SRC.TDS]TOKEN.C;1:540:tds_process_tokens(5BA7A0,
> 7ACFBA58, 7ACFBA50, 0x6914)
>
$1$DGA1808:[TSG.ACOCCIMIGLIO.VMS_1.FREETDS-0_91.SRC.TDS]TOKEN.C;1:543:tds_process_tokens()
> state is COMPLETED
>
$1$DGA1808:[TSG.ACOCCIMIGLIO.VMS_1.FREETDS-0_91.SRC.DBLIB]DBLIB.C;46:1716:dbresults()
> tds_process_tokens returned 2 (TDS_NO_MORE_RE?
> result_type TDS_DONE_RESULT
>
$1$DGA1808:[TSG.ACOCCIMIGLIO.VMS_1.FREETDS-0_91.SRC.DBLIB]DBLIB.C;46:1678:dbresults
> returning 2 (NO_MORE_RESULTS)
>
$1$DGA1808:[TSG.ACOCCIMIGLIO.VMS_1.FREETDS-0_91.SRC.DBLIB]BCP.C;3:2251:bcp_done(5C5E00)
>
$1$DGA1808:[TSG.ACOCCIMIGLIO.VMS_1.FREETDS-0_91.SRC.TDS]BULK.C;1:886:tds_bcp_done(5C6620,
> 7ACFBA50)
>
$1$DGA1808:[TSG.ACOCCIMIGLIO.VMS_1.FREETDS-0_91.SRC.TDS]NET.C;1:741:Sending
> packet
> 0000 0f 01 00 08 00 00 00 00- |........|
>
>
> thanks
>
> Angelo Coccimiglio
> _______________________________________________
> FreeTDS mailing list
> FreeTDS AT lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds
________________________________________
Craig A. Berry
mailto:craigberry AT mac.com
"... getting out of a sonnet is much more
difficult than getting in."
Brad Leithauser
_______________________________________________
FreeTDS mailing list
FreeTDS AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
-
[freetds] bcp_done always returns error if no data was inserted,
Angelo Coccimiglio, 12/03/2014
-
Re: [freetds] bcp_done always returns error if no data was inserted,
Craig A. Berry, 12/04/2014
- Re: [freetds] bcp_done always returns error if no data was inserted, Angelo Coccimiglio, 12/05/2014
-
Re: [freetds] bcp_done always returns error if no data was inserted,
Craig A. Berry, 12/04/2014
Archive powered by MHonArc 2.6.24.