How to get table columns info using ODBC? (SQLColumns returns an error)
I am trying to retrieve table columns info using a call to ODBC SQLColumnsW. This part of code works well with all other ODBC sources (Impala, MS SQL Server, etc)
The call looks like:
SQLRETURN ret = SQLColumnsW(stmt, catalogName, catalogNameLength, schemaName,
schemaNameLength, tableName, tableNameLength, NULL, 0 );
Driver (version 9.2.1.2, Windows) returns the error:
HY009:11376: [Vertica][ODBC] (11376) Invalid use of NULL pointer for column name.
Best Answer
-
SruthiA Administrator
It looks like error you are seeing is expected. if you pass NULL for column name.
https://docs.microsoft.com/en-us/sql/odbc/reference/syntax/sqlcolumns-function?view=sql-server-2017
If SQL_ATTR_METADATA_ID statement attribute was set to SQL_TRUE, and the SchemaName, TableName, or ColumnName argument was a null pointer then you will receive this error based on microsoft documentation. Please review the above link and set SQL_ATTR_METADATA_ID to SQL_FALSE and try to get table columns info5
Answers
Thank you, I set it to SQL_FALSE and it works now with Vertica (probably SQL Server just ignores this flag and allows NULL).