Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Does a declare cursor statement set sqlcode? 1

Status
Not open for further replies.
M

Member 310024

Guest
I work with COBOL/DB2 MVS on IBM Mainframe.
Does a declare cursor statement, containing the "EXEC SQL SELECT WHERE etc END-EXEC", actually set the return condition code SQLCODE?
Put differently, does it make sense to check the SQLCODE after the declare cursor statement (which doesn't include the OPEN), or will it just check the SQLCODE vlaue that happened to be setup by the last DBIO?
Put differently again, is it thru that the declare cursor statement doesn't don anything with SQLCODE, because it doesn't actually perform a DBIO (Data-Base IO) operation?
 
Hi Terminate,
The DECLARE CURSOR statement is a declarative statement like DECLARE TABLE, and is non-executable. The code is sometimes written next to the OPEN CURSOR statement so that when program debugging is required, you can see the cursor without having to page back to wherever it is declared. In this instance when section/paragraph containing the code if executed, the DECLARE CURSOR does absolutely nothing. I have often seen SQLCODE checked after this statement, which is incorrect. The SQLCODE will contain whatever result the last proper DB2 access returned.

If you are having problems with this, you should remove the SQLCODE check after the DECLARE CURSOR.

Hope this helps.

Marc
 
Thanks Marc, it did help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top