Skip to main content
Question

How to get table columns info using ODBC? (SQLColumns returns an error)

  • September 18, 2019
  • 2 replies
  • 11 views

rm_01

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.

2 replies

SruthiA
Forum|alt.badge.img+1
  • Participating Frequently
  • September 18, 2019

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 info


rm_01
  • Author
  • New Participant
  • September 19, 2019

Thank you, I set it to SQL_FALSE and it works now with Vertica (probably SQL Server just ignores this flag and allows NULL).