WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.



Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Using qLastCode to check these SQL Return Codes

Keywords: 	  qLastCode


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)


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:   W14185
Filename:   qLastCode to Check these SQL Return Codes.txt
File Created: 2017:07:28:13:58:33
Last Updated: 2001:01:09:16:02:10