Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OBDC Driver 11 for SQL Server query fails #30

Open
Profpatsch opened this issue Nov 25, 2016 · 3 comments
Open

OBDC Driver 11 for SQL Server query fails #30

Profpatsch opened this issue Nov 25, 2016 · 3 comments

Comments

@Profpatsch
Copy link
Contributor

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.

@Profpatsch
Copy link
Contributor Author

Same error with Driver versions 11 and 13.1 (all three official Microsoft drivers on Windows).

@Profpatsch
Copy link
Contributor Author

Profpatsch commented Nov 25, 2016

https://social.technet.microsoft.com/Forums/sqlserver/en-US/8db96b6b-4d79-4a69-a4d9-2f1d992db478/invalid-descriptor-index-calling-sqlgetdata?forum=sqldataaccess

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?

@Profpatsch
Copy link
Contributor Author

Also note that these are 1-indexed. (from another thread)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant