[freetds] bug in odbc driver (SQLNumResultCols) ??

Nilesh Dhawale ndhawale at gmail.com
Thu Oct 14 18:03:33 EDT 2004


It seems like SQLNumResultCols is not working right in the freeTDS
ODBC driver. I am on Solaris. The function returns 0 for the number of
columns in a table which has some columns. Return code is SQL_SUCCESS.
This happens if the statement is only "prepared", not "executed". I
tried on 6 different databases on windows and DB2 driver on AIX and
they all seem to work fine without having to "execute"! I am using
freetds-0.62.4 odbc driver. Is this a known issue?
A complete test program is attached. Here is a code snippet that shows
the problem.

/* Prepare the SQL statement */
retcode = SQLPrepare(hstmt1, "select * from MYTBL", SQL_NTS);
checkStatus(retcode, "SQLPrepare", SQL_HANDLE_STMT, hstmt1, 0);
/*
    // WITHOUT THIS EXECUTE, SQLNumResultCols does not return
    // THE CORRECT NUMBER OF COLS; MOREOVER THE RETURN
    // CODE FROM SQLNumResultCols indicates success
    // execute
   retcode = SQLExecute(hstmt1);
   printf("SQLExecute RET CODE : %d\n", retcode);
   checkStatus(retcode, "SQLExecute", SQL_HANDLE_STMT, hstmt1, 0);
*/
retcode = SQLNumResultCols(hstmt1, &numberOfColumns);
checkStatus(retcode, "SQLNumResultCols", SQL_HANDLE_STMT, hstmt1, 0);
printf("numberOfColumns: %d\n", numberOfColumns);
printf("RET VALUE: %d\n", retcode);

Rgds,
Nilesh
-- 
Nilesh Dhawale
http://www.cs.albany.edu/~nilesh
--


More information about the FreeTDS mailing list