Errors and RWDBStatus
When an error or warning is generated by an Access Module 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,, or
RWDBStatus::notConnected if a communication error occurred indicated by a
SQLSTATE code of
08XXX; for example, "
08001"
message: "SQL call failed" if an error occurred, or
"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,
"[Microsoft][ODBC SQL Server Driver] Invalid cursor state" vendorError1: the native error code parameter output from the call to
SQLGetDiagRec() vendorError2: the
SQLRETURN code from the failed SQL function.
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.errorCode() != RWDBStatus::ok) // Errors
cerr << stat.vendorMessage2();
else // Warnings
clog << stat.vendorMessage2();
}
All errors associated with the status will be reported.