SQLDescribeCol Function
When SQLDescribeCol returns either SQL_ERROR or SQL_SUCCESS_WITH_INFO, an associated SQLSTATE value can be obtained by calling SQLGetDiagRec with a HandleType of SQL_HANDLE_STMT and a Handle of StatementHandle. The following table lists the SQLSTATE values commonly returned by SQLDescribeCol and explains each one in the context of this function; the notation "(DM)" precedes the descriptions of SQLSTATEs returned by the Driver Manager. The return code associated with each SQLSTATE value is SQL_ERROR, unless noted otherwise.
|
SQLSTATE |
Error |
Description |
|---|---|---|
|
01000 |
General warning |
Driver-specific informational message. (Function returns SQL_SUCCESS_WITH_INFO.) |
|
01004 |
String data, right truncated |
The buffer *ColumnName was not large enough to return the entire column name, so the column name was truncated. The length of the untruncated column name is returned in *NameLengthPtr. (Function returns SQL_SUCCESS_WITH_INFO.) |
|
07005 |
Prepared statement not a cursor-specification |
The statement associated with the StatementHandle did not return a result set. There were no columns to describe. |
|
07009 |
Invalid descriptor index |
(DM) The value specified for the argument ColumnNumber was equal to 0, and the SQL_ATTR_USE_BOOKMARKS statement option was SQL_UB_OFF. The value specified for the argument ColumnNumber was greater than the number of columns in the result set. |
|
08S01 |
Communication link failure |
The communication link between the driver and the data source to which the driver was connected failed before the function completed processing. |
|
HY000 |
General error |
An error occurred for which there was no specific SQLSTATE and for which no implementation-specific SQLSTATE was defined. The error message returned by SQLGetDiagRec in the *MessageText buffer describes the error and its cause. |
|
HY001 |
Memory allocation failure |
The driver was unable to allocate memory required to support execution or completion of the function. |
|
HY008 |
Operation canceled |
Asynchronous processing was enabled for the StatementHandle. The function was called, and before it completed execution, SQLCancel or SQLCancelHandle was called on the StatementHandle. Then the function was called again on the StatementHandle. The function was called, and before it completed execution, SQLCancel or SQLCancelHandle was called on the StatementHandle from a different thread in a multithread application. |
|
HY010 |
Function sequence error |
(DM) An asynchronously executing function was called for the connection handle that is associated with the StatementHandle. This asynchronous function was still executing when SQLDescribeCol was called. (DM) SQLExecute, SQLExecDirect, or SQLMoreResults was called for the StatementHandle and returned SQL_PARAM_DATA_AVAILABLE. This function was called before data was retrieved for all streamed parameters. (DM) An asynchronously executing function (not this one) was called for the StatementHandle and was still executing when this function was called. (DM) The function was called prior to calling SQLPrepare, SQLExecute, or a catalog function on the statement handle. (DM) SQLExecute, SQLExecDirect, SQLBulkOperations, or SQLSetPos was called for the StatementHandle and returned SQL_NEED_DATA. This function was called before data was sent for all data-at-execution parameters or columns. |
|
HY013 |
Memory management error |
The function call could not be processed because the underlying memory objects could not be accessed, possibly because of low memory conditions. |
|
HY090 |
Invalid string or buffer length |
(DM) The value specified for argument BufferLength was less than 0. |
|
HY117 |
Connection is suspended due to unknown transaction state. Only disconnect and read-only functions are allowed. |
(DM) For more information about suspended state, see SQLEndTran Function. |
|
HYT01 |
Connection timeout expired |
The connection timeout period expired before the data source responded to the request. The connection timeout period is set through SQLSetConnectAttr, SQL_ATTR_CONNECTION_TIMEOUT. |
|
IM001 |
Driver does not support this function |
(DM) The driver associated with the StatementHandle does not support the function. |
|
IM017 |
Polling is disabled in asynchronous notification mode |
Whenever the notification model is used, polling is disabled. |
|
IM018 |
SQLCompleteAsync has not been called to complete the previous asynchronous operation on this handle. |
If the previous function call on the handle returns SQL_STILL_EXECUTING and if notification mode is enabled, SQLCompleteAsync must be called on the handle to do post-processing and complete the operation. |
SQLDescribeCol can return any SQLSTATE that can be returned by SQLPrepare or SQLExecute when called after SQLPrepare and before SQLExecute, depending on when the data source evaluates the SQL statement associated with the statement handle.
For performance reasons, an application should not call SQLDescribeCol before executing a statement.
An application typically calls SQLDescribeCol after a call to SQLPrepare and before or after the associated call to SQLExecute. An application can also call SQLDescribeCol after a call to SQLExecDirect. For more information, see Result Set Metadata.
SQLDescribeCol retrieves the column name, type, and length generated by a SELECT statement. If the column is an expression, *ColumnName is either an empty string or a driver-defined name.
Note
|
|---|
|
ODBC supports SQL_NULLABLE_UNKNOWN as an extension, even though the Open Group and SQL Access Group Call Level Interface specification does not specify the option for SQLDescribeCol. |
Note