The ODBC driver currently allows the user to bypass ODBC state check for open cursors. According to the standard an invalid cursor state (24000) error should be returned for API calls that may generate a result set or requires an open cursor to exist.
For example, when calling SQLExecDirect when a cursor is open an error should be returned and the SQLSTATE set to 24000. Similarly, calling SQLDescribeCol when there is no result set should cause an Invalid cursor state error. In some situations ODBC Driver Manager generates this error and in other cases the driver returns this error.
ODBC driver has a DSN option StCheckLevel=[0 | 1 | 2] to control this behavior:
- 0 (default) No check is made on cursor state when calling functions; backward compatibility is provided.
- 1 The application must not be in an open cursor state when calling a function that generates a result set.
- 2 The application must not be in an open cursor state when calling a function that generates a result set, or when calling functions that require an open cursor state.