[freetds] SQL executation status in FreeTDS

Mostafa Fazle Rabbi MostafaFazleRabbi at prettygirl.com.au
Mon Dec 13 22:43:08 EST 2004


Hi,
 
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;
}

while ((rc=tds_process_result_tokens(tds,
&result_type,NULL))==TDS_SUCCEED) {
  switch (result_type) {
    case TDS_DONE_RESULT:
    case TDS_DONEPROC_RESULT:
    case TDS_DONEINPROC_RESULT:
    /* ignore possible spurious result (TDS7+ send it) */
    case TDS_STATUS_RESULT:
       break;

    default:
       fprintf(stderr, "Error: query should not return results\n");
       return TDS_FAIL;
  }
}

 if (rc == TDS_FAIL) {
   printf("tds_process_result_tokens() returned TDS_FAIL for '%s'\n",
query);
   return TDS_FAIL;
 } else if (rc != TDS_NO_MORE_RESULTS) {
         printf("tds_process_result_tokens() unexpected return\n");
         return TDS_FAIL;
 }

 return TDS_SUCCEED;

}

Will be a great help if someone could help me pls.
Is there any better way to get the SQL execution status from 
the MS SQL Server ?

Regards,

Mostafa

The information contained in this e-mail communication may be confidential. You should only read, disclose, re-transmit, copy, distribute, act in reliance on or commercialise the information if you are authorised to do so. If you are not the intended recipient of this e-mail communication, please immediately notify the sender by e-mail and then destroy any electronic or paper copy of this message.

Any views expressed in this e-mail communication are those of the individual sender, except where the sender specifically states them to be the views of PGFG or any of its divisions. PGFG or any of its divisions does not represent, warrant or guarantee that the integrity of this communication has been maintained nor that the communication is free of errors, virus or interference.




More information about the FreeTDS mailing list