DBTools.h++ handles errors differently depending upon how they are generated. The following sections describe error messages used with the DB2 CLI access library.
When an error or warning is generated by an access library call to the DB2 CLI, information about the event is retrieved via a call to SQLError() and transferred to an RWDBStatus. This RWDBStatus object is passed as a parameter to the installed error handler. RWDBStatus uses the following format to describe events reported by DB2 CLI:
errorCode: RWDBStatus::serverError if an error occurred, or RWDBStatus::ok if a warning is being generated
message: "SQL call failed." if an error occurred, or "SQL success with info" if a warning is being generated.
vendorMessage1: The state parameter output from the SQLError()call; for example, "21S01".
vendorMessage2: The error message parameter output from the SQLError() call.
vendorError1: The native error code parameter output from the SQLError() call.
vendorError2: Severity. 1 if an error occurred or 0 for a warning.
An application can use the mapping shown above to write an error handler that reports errors on cerr and issues warnings on clog. For example:
void myErrorHandler(const RWDBStatus& stat) { if (stat.vendorError1()) // Errors cerr << stat.vendorMessage2(); else // Warnings clog << stat.vendorMessage2(); }
All errors associated with the status will be reported.
©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.