-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
db_odbc - invalid cursor state error when calling stored procedures #4
Comments
This is the part that confuses me a bit, although I'm new to ODBC. If I SQLDirectExec a statement such as I've worked around this locally with a "fetch" parameter that decides whether or not to fetch, but it would be better to have prepareFetchDirect know if a fetch is necessary. I'm just not sure how to get the API to tell me this. Another thing I have tried, and which seems to work, is this:
Basically, check if there are results with SQLNumResultCols before deciding whether or not to fetch. |
Adding an example from mssql that might be related. In the example below, the data is inserted into the table so the error occurs afterwards. getAllRows isn't executed.
Error output:
|
db_odbc.exec (and probably the other variations of exec) raises an 'Invalid Cursor State' error when attempting to call a stored procedure as it tries to fetch results as the last step and stored procedures won't have data to fetch (a 'stored procedure' returns nothing while a 'stored function' returns something).
I couldn't see anything related to stored procedures (or stored procedures within packages in my case as I'm mucking around in Oracle) within db_odbc so I tried the exec function and it didn't work. Apologies if I've just missed a relevant API.
I think this is a generic ODBC consideration rather than being vendor-specific.
Example
Current Output
Expected Output
No output (but no error)
Possible Solution
I found documentation discussing the 'Invalid Cursor State' error:
The same sort of comment exists in the SQLExecDirect docs too.
I can see logic like the following in db_odbc:
It seems the API doesn't have a way to say "don't do a fetch at the end". I imagine the solution would be some combination of:
For what it's worth, I tried a copy-paste-tweak version of exec with the SQLFetch commented out and it appeared to work when calling stored procedures. (The SQLExecute call returned 0 (SQL_SUCCESS).)
Additional Information
(but this has been an issue for ages.)
Windows 10 / Oracle instant client 19.
The text was updated successfully, but these errors were encountered: