Error Messages

Error messages produced by the data source or by the gateway must be mapped to corresponding ODBC errors. Error mapping can be accomplished directly by the gateway or by the Open Data Services ODBC driver. Gateways that do not support ODBC error mapping use SQL Server driver error code mapping, which causes the gateway to map native errors to SQL Server error codes, and the driver to then map those codes to ODBC errors.

In order to map ODBC more directly to the underlying DBMS, gateways can perform the mapping directly. All mapping from gateway or remote DBMS errors to ODBC error codes is represented in the message text string passed to the client. Gateways construct the srv_message string to contain both the ODBC error code mapping and the gateway or DBMS error text. The error message consists of parts, delimited by brackets, using the following format:

[SQLSTATE code][vendor id][native error number][gateway name] [remote DBMS ID]:error text

where

SQLSTATE code
Is the ODBC code that maps to the gateway error or DBMS error. The ODBC driver for the gateways strips off this section and passes it to the client in the szSQLState return parameter for the ODBC SQLError API. If the DBMS returns SQLSTATE as part of its native error system, the gateway must map any DBMS SQLSTATE extensions to the appropriate ODBC SQLSTATE.
vendor ID
Is a code for the gateway vendor. This code is chosen by the gateway developer.
native error number
Is the ASCII representation of the "native" error number from a remote DBMS. This number is returned in the pfNativeError return parameter for the ODBC SQLError API. The native error number corresponds to a numeric DBMS-specific error code. For example, for a DB2 error, the SQLCA.SQLCODE would be returned in this section. This section is empty when the error is related to the gateway or does not represent a DBMS error.
gateway name
Is the name of the gateway component, for example, Rdb Gateway.
remote DBMS ID
In cases where a DBMS-specific error is returned, this section contains the name of the DBMS being accessed, such as DB2 or SQL/400®.
error text
Is the text of the error message.