Skip to Content.
Sympa Menu

freetds - [freetds] SQLExecDirect returns SQL_NO_DATA

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "John Wythe (work)" <jwythe AT silksystems.com>
  • To: freetds AT lists.ibiblio.org
  • Subject: [freetds] SQLExecDirect returns SQL_NO_DATA
  • Date: Fri, 10 Mar 2006 19:49:06 -0800

I have found a problem with SQLExecDirect. If I execute a query that is not
intended to return data, I get an SQL_NO_DATA result. This is not what the
same function returns on Windows, it returns SQL_SUCCESS. If I use ISQL to
execute the query, which uses SQLPrepare, and SQLExecute, I get the proper
result.

I have looked at the source, and found the problem. Maybe you can look at
the before and after code snippets and tell me if I made the right change, or
direct me how to make the correct change. Eventually the fix should
probably be incorperated into the main code. Basically, from debugging the
program, the done flag doesn't get set, and the program tries to get another
token, but there aren't any more, so it thinks it was trying to do a SQLFetch
for more data which in that case should return SQL_NO_DATA, since, in this
case in_row is zero, this is not the case. My question would be whether or
not TDS_DONEPROC_RESULT should also do this?

Snippets from src/odbc/odbc.c function SQLExecDirect

Before:
case TDS_PARAM_RESULT:
odbc_set_return_params(stmt);
break;

case TDS_DONE_RESULT:
case TDS_DONEPROC_RESULT:
if (done_flags & TDS_DONE_COUNT) {
got_rows = 1;
After:

case TDS_PARAM_RESULT:
odbc_set_return_params(stmt);
break;

case TDS_DONE_RESULT:
if (!in_row && !(done_flags & TDS_DONE_COUNT) && !(done_flags &
TDS_DONE_ERROR))
/* prevent queries with no result set from returning SQL_NO_DATA jww
*/
stmt->row_count = 0;
else {
if (done_flags & TDS_DONE_COUNT) {
got_rows = 1;
stmt->row_count = tds->rows_affected;
}
if (done_flags & TDS_DONE_ERROR)
stmt->errs.lastrc = SQL_ERROR;
}
done = 1;
break;
case TDS_DONEPROC_RESULT:
if (done_flags & TDS_DONE_COUNT) {
got_rows = 1;

Thanks

John




Archive powered by MHonArc 2.6.24.

Top of Page