Skip to Content.
Sympa Menu

freetds - Re: [freetds] SQL executation status in FreeTDS

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "James K. Lowden" <jklowden AT schemamania.org>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] SQL executation status in FreeTDS
  • Date: Tue, 14 Dec 2004 00:58:19 -0500

"Mostafa Fazle Rabbi" <MostafaFazleRabbi AT prettygirl.com.au> wrote:
>
> I am using FreeTDS to insert data into MS Enterprise Server 2000.
> Whenever I send the SQL to the server it is returning TDS SUCCESS
> as execution status of the command although the actual insert statement
> failed (no data was inserted into the table). Following function is used
> to
> execute the query and it is always returning TDS_SUCCEED.
>
> static int execute_query(TDSSOCKET * tds, const char *query)
> {
> int rc;
> int result_type;
>
> rc = tds_submit_query(tds, query);
>
> if (rc != TDS_SUCCEED) {
> printf("tds_submit_query() failed for query");
> return TDS_FAIL;
> }

Please don't use libtds for application programming. It changes
frequently, and we don't make any effort to notify users of deprecated
functions. It exposes many tedious aspects of the TDS protocols that the
client libraries subsume.

That said, the return code for any function that sends a query (including
tds_submit_query) indicates merely whether or not the SQL text was
successfully transmitted to the server. It does not say anything about
what the server thought of the query. IOW, it tells you if the envelope
was delivered, not whether or not the letter was read.

To discover the fate of your (delivered) query, you have to ask, cf.
dbresults(). The client library will read the DONE packet, along with any
ERROR packets. The return code will convey yea/nay, and the error packet
(if any) will include an error number and explanatory text.

HTH.

--jkl




Archive powered by MHonArc 2.6.24.

Top of Page