Each DB-Library server message handler parameter maps to a field in the CS_SERVERMSG structure. In addition, CS_SERVERMSG includes four fields that do not map to DB-Library message handler parameters. These parameters represent the lengths, in bytes, of the message text, server name, and procedure name, and a bitmask indicator used for sequenced message and extended error message information.
DB-Library message handler parameters |
Description of parameter or field |
Client-Library CS_SERVERMSG structure fields |
---|---|---|
severity |
The severity of the error message |
severity |
msgno |
The identifying number of the error message |
msgnumber |
msgstate |
The server error state associated with the server message |
state |
msgtxt |
The text of the server message |
text |
(none) |
The length, in bytes, of text |
textlen |
srvname |
The name of the server that generated the message |
svrname |
(none) |
The length, in bytes, of svrname |
svrnlen |
procname |
The name of the stored procedure that caused the message, if any |
proc |
(none) |
The length, in bytes, of proc |
proclen |
line |
The number of the command batch or stored procedure line, if any, that generated the message |
line |
(none) |
A bitmask indicator of whether msgstring contains an entire message or what part of a sequenced message it contains |
status |
(none) |
A byte string containing the SQL state value associated with the error, if any |
sqlstate |
Server message handlers for DB-Library applications must return 0. Server message handlers for Client-Library applications must return CS_SUCCEED. If a Client-Library server message handler returns any value other than CS_SUCCEED, Client-Library marks the connection as “dead,” and it becomes unusable. A return of any code but CS_SUCCEED marks the connection dead from both the server and client message callbacks.
See the “Callbacks” topics page in the Open Client Client-Library/C Reference Manual for an example server-message callback.