Recently, I was confused with an error in my program as stated in my other question: Strange Cursor behavior while declaring same cursor multiple times
Upon using a lot of printf
s etc. I figured out that:
EXEC SQL Declare abc Cursor for select..
doesn't change/return sqlca.sqlcode
EXEC SQL Open abc;..
returns sqlca.sqlcode
EXEC SQL Fetch abc into .. ; ..
returns sqlca.sqlcode
EXEC SQL Close abc; ..
returns sqlca.sqlcode
EXEC SQL Commit; ..
returns sqlca.sqlcode
I would like to understand why the declare didn't return any code because we are using EXEC SQL
declare & I thought EXEC SQL
always returns sqlca.sqlcode
.
Also, is there any documentation for Oracle Pro*C that explains all this?
Thanks in advance.
According to Oracle's documentation on DEF_SQLCODE, the described behavior would appear to be a bug; if you have set #include <sqlqca.h>
or EXEC SQL INCLUDE SQLCA;
and set DEF_SQLCODE=YES
in your code, then it should have returned a code.
Their documentation on handling runtime errors might be useful.