AnsweredAssumed Answered

via ODBC driver: calling SQLNumResultCols() after SQLPrepare() on a SELECT returns zero columns

Question asked by CharlesBenet on Nov 18, 2010
Latest reply on Jan 27, 2011 by TSGal

Summary

via ODBC driver: calling SQLNumResultCols() after SQLPrepare() on a SELECT returns zero columns

Product

FileMaker Pro

Version

11.0.2

Operating system version

Windows Server 2003 R2 SP2 Standard Edition

Description of the issue

Calling SQLPrepare() on a SELECT statement and then immediately following that with a call to SQLNumResultCols() returns zero for the number of columns. If I then call SQLExecute() and then call SQLNumResultCols() again, then the correct number of columns (at least it's non-zero!) is returned.

Using odbctest.exe (available from MicroSoft)

Env. Attr. SQL_ATTR_ODBC_VERSION set to SQL_OV_ODBC3

Successfully connected to DSN 'onetabletest'.

SQLPrepare:
In: StatementHandle = 0x003A1790,
   StatementText = "select  "_kp_claimID" from "CLM_claims"",
    TextLength = 39
Return: SQL_SUCCESS=0
SQLNumResultCols:
In: StatementHandle = 0x003A1790, ColumnCountPtr = 0x0015A640
Return: SQL_SUCCESS=0
Out: *ColumnCountPtr = 0  <--- incorrect
If I then call SQLExecute() to execute the SELECT and then call
SQLNumResultCols() again, the correct value (1) is returned:

SQLExecute:
In: StatementHandle = 0x003A1790
Return: SQL_SUCCESS=0
SQLNumResultCols:
In: StatementHandle = 0x003A1790, ColumnCountPtr = 0x0015A640
Return: SQL_SUCCESS=0
Out: *ColumnCountPtr = 1  <---correct

The Microsoft ODBC doc for SQLNumResultCols() says:

"SQLNumResultCols can be called successfully only when the statement is in the prepared, executed, or positioned state."


DriverName:fmodbc32.dll, DriverVer:11.2.70.0
DBMS Name:FileMaker, DBMS Version:11.0.2

Steps to reproduce the problem

Use odbctest.exe as outlined in the "Description of this issue" area.

Column "_kp_claimID" in table "CLM_claims" is a numeric column.

The same problem occurs with a simple statement like
     SELECT COUNT(*) FROM "CLM_tables"

Expected result

In a SQLPrepare() SQLNumResultCols() sequence, SQLNumResultCols() should return the number of columns in the SELECT statement.

Actual result

In a SQLPrepare() SQLNumResultCols() sequence, SQLNumResultCols() is  returning zero for the number of columns in the SELECT statement.

Outcomes