This article was previously published under Q110473
This article has been archived. It is offered "as is" and will no longer be updated.
This article discusses how the Driver Manager calls a driver'sSQLError to flush the errors in the driver's error buffer. Chapter 16of the ODBC SDK "Programmer's Reference" documents the ODBC conventionfor error text, return codes, and rules for handling error conditions.
Under the Returning Error Messages section in chapter 16, itreads:
Each time the application calls SQLError, the driver returns the next error message in the buffer. When the application calls a different function, the driver discards the current contents of the error message buffer.
It is unclear from the last sentence whether the driver clears the currenterror buffer on entry into the next function, or whether the Driver Managercalls the driver to clear its error buffer before entry into the nextfunction.
This article explains how an application calls ODBC function B() after aprevious call to ODBC function A(), the Driver Manager actually calls thedriver's SQLError() first and then calls the driver's function B().
The implication of the Driver Manager calling the Driver's SQLError()is that on entry to function B() in the Driver, the Driver hasalready cleared the error buffer. Developers need to note this whendebugging their drivers.
Also, when the Driver Manager calls the Driver's SQLError(), it passes theappropriate ODBC handles, but for other arguments to SQLError() likeszSQLState, pfNativeError, it passes a NULL. The SQLError() function forDrivers must be written, such that when passed NULL arguments foreverything except ODBC handles in SQLError(), the errors in the Driver'serror buffer are cleared.
The following is a diagram showing how this process is accomplished by theDriver Manager.