hdbc / hdbc-odbc

ODBC driver for HDBC
BSD 3-Clause "New" or "Revised" License
26 stars 34 forks source link

mssql varbinary(max) fails when selecting data #21

Open gbwey opened 9 years ago

gbwey commented 9 years ago

Hi, I am getting an "Invalid Descriptor Index" error (as below) when selecting from tables that have varbinary(max) fields. This used to work about a year ago (not sure if that helps). Anyway here is a small example that fails using HDBC-odbc-2.4.0.1.

Thanks for any help you give me. Grant

CREATE TABLE [dbo].[testblob]([id] [bigint] IDENTITY%281,1%29 NOT NULL, [bs1] [varbinary]%28max%29 NULL, PRIMARY KEY CLUSTERED %28 [id] ASC %29)

insert into testblob values(convert(varbinary(max),'xxxxx'))

conn <- H.connectODBC connectionString stmt1 <- H.prepare conn "select * from testblob" vals <- H.execute stmt1 [] results <- H.fetchAllRowsAL stmt1 mapM_ print results

*\ Exception: SqlError {seState = "[\"07009\"]", seNativeError = -1, seErrorMsg = "sqlGetData: [\"0: [Microsoft][ODBC Driver 11 for SQL Server]Invalid Descriptor Index\"]"}

PiotrJustyna commented 8 years ago

I have a similar problem, but with uniqueidentifier.

PiotrJustyna commented 8 years ago

OK, my issue is now solved. What caused it was the uniqueidentifier but what resolved it was to have the column it represents as the last one in the select statement. Order of columns does not matter in my case.