DBTools.h++ handles errors differently depending upon how they are generated. The following sections describe error messages used with the ODBC access library.
Because DBTools.h++ makes no attempt to simulate behavior that is not provided in the ODBC API and ODBC SQL grammar, certain DBTools.h++ functions are reported as errors using the error code RWDBStatus::notSupported. For example, there is no ODBC grammar that generally supports the idea of an RWDBDatabase::createProcedure() function, so it is reported as "not supported."
There is a much broader range of possible errors that depend entirely on the underlying ODBC driver in use. Errors of this sort are most likely to occur during the execution of advanced SQL via a call to SQLExecute(). These errors are reported using the error code RWDBStatus::serverError.
We make no attempt to mitigate against such errors, but when an error does occur, information is transferred to DBTools.h++ objects as described below.
When an error or warning is generated by an access library call to the ODBC API, information about the event is retrieved via a call to SQLGetDiagRec() and transferred to an RWDBStatus. This RWDBStatus object is passed as a parameter to the installed error handler. The following list provides the format that RWDBStatus uses to describe events reported by the ODBC driver:
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 SQLGetDiagRec() call; for example, "21S01"
vendorMessage2: the error message parameter output from the SQLGetDiagRec() call; for example, "Driver not capable"
vendorError1: the native error code parameter output from the SQLGetDiagRec() call
vendorError2: severity: 1 if an error occurred, or 0 if a warning is being generated
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.