SQLGetDiagRec
Function
SQLGetDiagRec is used to return the current values of multiple fields in a diagnostic record that contains error, warning, and status information.
Prototype
SQLRETURN SQLGetDiagRec(SQLSMALLINT HandleType
SQLHANDLE Handle,
SQLSMALLINT RecNumber,
SQLCHAR *SQLState,
SQLINTEGER *NativeErrorPtr,
SQLCHAR *MessageText,
SQLSMALLINT BufferLength
SQLSMALLINT *TextLengthPtr);
Parameter
Table 1 SQLGetDiagRec parameters
Return Value
- SQL_SUCCESS indicates that the call succeeded.
- SQL_SUCCESS_WITH_INFO indicates that some warning information is displayed.
- SQL_ERROR indicates major errors, such as memory allocation and connection failures.
- SQL_INVALID_HANDLE indicates that invalid handles were called. This value may also be returned by other APIs.
Precautions
SQLGetDiagRec does not release diagnostic records for itself. It uses the following return values to report execution results:
- SQL_SUCCESS indicates that the function successfully returns diagnostic information.
- SQL_SUCCESS_WITH_INFO indicates that the *MessageText buffer is too small to hold the requested diagnostic information. No diagnostic records are generated.
- SQL_INVALID_HANDLE indicates that the handle indicated by HandType and Handle is an invalid handle.
- SQL_ERROR indicates that RecNumber is less than or equal to 0 or that BufferLength is smaller than 0.
If an ODBC function returns SQL_ERROR or SQL_SUCCESS_WITH_INFO, the application can call SQLGetDiagRec to obtain the SQLSTATE value. The possible SQLSTATE values are listed as follows:
Table 2 SQLSTATE values
Example
See Examples.
Feedback