Replacing DB-Library error handlers

The DB-Library error handler (installed with dberrhandle) should be replaced with a CS-Library error handler and a Client-Library client message handler (installed with cs_config and ct_callback, respectively). The CS-Library handler is called for errors occurring in CS-Library calls, and the Client-Library handler is called for errors occurring in Client-Library calls.

Both the CS-Library and Client-Library handlers take a CS_CLIENTMSG structure. Each DB-Library error-handler parameter maps to a field in the CS_CLIENTMSG structure.

In addition, CS_CLIENTMSG includes three fields that do not map to DB-Library error handler parameters. For example, CS_CLIENTMSG provides integer fields that specify the lengths, in bytes, of the message text and operating system message text. These fields allow the use of character sets that do not support null terminators.

Table 5-4 shows the correspondence between DB-Library error handler parameters and CS_CLIENTMSG fields:

Table 5-4: DB-Library error handler parameters vs. CS_CLIENTMSG fields

DB-Library error handler parameters

Description of parameter or field

Client-Library CS_CLIENTMSG structure fields

severity

The severity of the error

severity

dberr

The identifying number of the error

msgnumber

dberrstr

The printable message description string

msgstring

(none)

The length, in bytes, of msgstring

msgstringlen

oserr

The operating system-specific error number

osnumber

oserrstr

The printable operating system message description string

osstring

(none)

The length, in bytes, of osstring

osstringlen

(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