Using qLastCode to check these SQL Return Codes
Keywords: qLastCode
Question:
Here is a typical ODBC command, taken directly from the ODBC extender help library. This line, *retcode = qLastCode()*, confuses me.Can someone explain to me the difference between the values of henv, and retcode? They seem to contain the same value, should they? What is the command *qLastCode()* necessary for?
Thanks in advance.
henv = qAllocEnv() If henv == -1 retcode = qLastCode() Message("qAllocEnv failed", retcode) Exit EndifAnswer:
In the case of *Some* of the ODBC extender functions, the functions can return more than one value.For Example, qAllocConnect returns an SQL connection handle.
In order to get the SQL error code, you would need to use the function qLastCode which returns the SQL return code that was set by the last SQL function call.
Use the return value(ie., henv) of qAllocConnect as SQL connection handle.
Use qLastCode (ie., retcode) to check these SQL return codes.....
SQL Return Codes Constant Meaning Value @qError SQL_ERROR -1 @qBadHandle SQL_INVALID_HANDLE -2 @qSuccess SQL_SUCCESS 0 @qSuccessInfo SQL_SUCCESS_WITH_INFO 1 @qStillEx SQL_STILL_EXECUTING 2 @qNeedData SQL_NEED_DAT 99 @qNoData SQL_NO_DATA_FOUND 100
Article ID: W14185Filename: qLastCode to Check these SQL Return Codes.txt