Status and Error Retrieval Procedures
When any ODBC call fails, the driver retains error information until the next ODBC call. The error state and error text is retrieved from the driver with the SQLError function.
Syntax
RETCODE SQLError(henv,hdbc,hstmt,szSqlState,pfNativeError,szErrorMsg,cbErrorMsgMax,pcbErrorMsg)
Description
SQLError returns error or status information. An application typically calls SQLError when a previous call to an ODBC function returns SQL_ERROR or SQL_SUCCESS_WITH_INFO. The application can, however, call SQLError after any ODBC function call.
Parameters
This table describes the parameters:
Argument |
Type |
Use |
Description |
---|---|---|---|
henv |
HENV |
Input |
Environment handle or SQL_NULL_HENV. |
hdbc |
HDBC |
Input |
Connection handle or SQL_NULL_HDBC. |
hstmt |
HSTMT |
Input |
Statement handle or SQL_NULL_HSTMT. |
szSqlState |
UCHAR FAR * |
Output |
SQLSTATE as null terminated string. |
pfNativeError |
SDWORD FAR * |
Output |
Native error code (specific to the data source). |
szErrorMsg |
UCHAR FAR * |
Output |
Pointer to storage for the error message text. |
cbErrorMsgMax |
SWORD |
Input |
Maximum length of the szErrorMsg buffer. This must be less than or equal to SQL_MAX_MESSAGE_LENGTH - 1. |
pcbErrorMsg |
SWORD FAR * |
Output |
Pointer to the total number of bytes (excluding the null termination byte) available to return in szErrorMsg. If the number of bytes available to return is greater than or equal to cbErrorMsgMax, the error message text in szErrorMsg is truncated to cbErrorMsgMax – 1 bytes. |