This function returns the diagnostic information associated with the most recently called function for a particular statement, connection, or environment handle.
Syntax :
RETCODE SQLGetDiagRec( hType,handle, recNum, sqlState, nativeErr, errMsg, errMsgMax, pcbErrMsg);
Arguments :
The arguments for SQLGetDiagRec are listed in below table.
| Type | Name | Description |
| SQLSMALLINT | hType | Handle type |
| SQLINTEGER | handle | Handle for which the diagnostic information is wanted. |
| SQLSMALLINT | recNum | If there are multiple errors, this indicates which one should be retrieved. If header information is requested, this must be 0. The first error record is number 1. |
| SQLCHAR* | sqlState | SQLSTATE as a string of 5 characters terminated by a null character. The first 2 characters indicate error class; the next 3 indicate subclass. |
| SQLINTEGER* | nativeErr | Native error code |
| SQLCHAR* | errMsg | Pointer to buffer to contain the implementation defined message text. |
| SQLSMALLINT | errMsgMax | Maximum (that is, the allocated) length of the buffer errMsg |
| SQLSMALLINT* | pcbErrMsg | Pointer to total number of bytes available to return to the errMsg buffer. |