21 Aug 19:16
Prepared statements with no parameters exhibit strange behaviour
From: Chris Reeves <csr2 <at> st-andrews.ac.uk>
Subject: Prepared statements with no parameters exhibit strange behaviour
Newsgroups: gmane.comp.db.tds.freetds
Date: 2008-08-21 17:17:38 GMT
Subject: Prepared statements with no parameters exhibit strange behaviour
Newsgroups: gmane.comp.db.tds.freetds
Date: 2008-08-21 17:17:38 GMT
I noticed some strange behaviour last week when using ODBC to prepare and
execute a statement with no parameters. This could be readily reproduced using
a call sequence along the lines of:
SQLPrepare(handle, "select * from foo where bar = 1", SQL_NTS);
while (1) {
SQLExecute(handle)
SQLNumResultCols(handle, &nCols)
printf("Number of columns: %i", nCols);
while (SQLFetch(handle) != SQL_NO_DATA) {
// Some code (or no code)
}
SQLFreeStmt(handle, SQL_CLOSE)
}
This call sequence would produce something like:
Number of columns: 65
Number of columns: 0
Number of columns: 65
Number of columns: 0
Number of columns: 65
Number of columns: 0
Number of columns: 65
Number of columns: 0
...
assuming it didn't just die with:
08S01 (20004): [unixODBC][FreeTDS][SQL Server]Read from the server failed
on the third call to SQLExecute.
Removing the calls to SQLFetch would eliminate the problem (number of columns
(Continue reading)
RSS Feed