DB-Library distinguishes between errors originating from SQL server and errors generated within DB-Library itself. DBTools.h++ honors this distinction by assigning error code serverError to errors from SQL Server and error code vendorLib to ones from DB-Library.
RWDBStatus uses the following format to report errors from DB-Library:
errorCode: vendorLib, unless the DB-Library severity is 0. If severity is 0, errorCode is set to RWDBStatus::ok, and the user-installed error handler is invoked.
message: Vendor Library Error: %s, where %s is the error text from DB-Library (dberrstr).
vendorMessage1: The text reported by DB-Library as an operating system error, if any (oserrstr).
vendorMessage2: Unused.
vendorError1: The DB-Library error number. (dberr, unless
dberr == DBNOERR, then oserr).
vendorError2: The error's severity level (severity).
Notice that errors with a severity level of 0 are given special handling when such errors occur, the RWDBStatus::errorCode is set to RWDBStatus::ok, the rest of the RWDBStatus is populated, and the application's error handler (if any) is invoked. This means that DBTools.h++ applications will ignore these errors by default, but can process them if necessary. It also means that your error handler should check vendorError2 (severity) before raising an exception.
The following format shows how RWDBStatus reports messages from SQL Server:
errorCode: serverError, unless (1) severity and message number are both 0, or (2) message number is one of: 5701, 5703, 5704. In either case, errorCode is set to RWDBStatus::ok, and the user-installed error handler is invoked.
message: If severity is not 0, Server Error: %s, where %s is the text of the SQL Server message (msgtxt). Otherwise message is the message text.
vendorMessage1: Name of the SQL Server reporting the error (srvname).
vendorMessage2: Unused.
vendorError1: SQL Server message number (msgno).
vendorError2: The error's severity level (severity).
Notice that RWDBStatus provides special handling for messages that result from SQL PRINT statements (in which both severity and message number are 0) and for "context switch" messages (for example, "Changed database context to master"). When these messages occur, the RWDBStatus::errorCode is set to RWDBStatus::ok, the rest of the RWDBStatus is populated, and the application's error handler (if any) is invoked. Since, in such cases, errorCode is ok, DBTools.h++ applications will ignore these errors by default. However, the error information itself is still accessible if the application needs to check it. Your error handler should check vendorError2 (severity) before raising an exception.
©Copyright 1999, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.