OBDC Driver 11 for SQL Server query fails
Profpatsch opened this issue · 3 comments
I can create a connection without problem. I have at small test table
id: bigint
name: nvarchar(max)
And when I try
> quickQuery c "select id from test" []
[[SqlInt64 123]]
> quickQuery c "select * from test" []
*** Exception: SqlError {seState = "[\"07009\"]", seNativeError = -1, seErrorMsg = "sqlGetData: [\"0: [Microsoft][ODBC Driver 13 for SQL Server]Invalid Descriptor Index\"]"}
Same error for select name
and select id,name
.
StackOverflow has some ideas, but it doesn’t seem to fit this problem.
Same error with Driver versions 11 and 13.1 (all three official Microsoft drivers on Windows).
This is the documented behavior for SQL Native Client. Columns must be retrieved in increasing ordinal order. This part of the documentation was the same for SQL Server 7, so SQL Native Client has not introduced new behavior here. Otherdrivers may support fetching columns in random order. Applications can determine the behavior of a driver by calling SQLGetInfo for SQL_GETDATA_EXTENSIONS and using the bitmas SQL_GD_ANY_ORDER. By enforcing sequential order, the ODBC driver avoids having to have an intermediate row buffer, so there is a gain in efficiency and memory utilization.
I assume HDBC doesn’t fetch them necessarily in increasing order?
Also note that these are 1-indexed. (from another thread)