IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Testing rerad cursor for status with predicate


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
John F Dutcher

New User


Joined: 02 Apr 2008
Posts: 11
Location: Harrisburg, PA

PostPosted: Fri May 19, 2017 9:35 pm
Reply with quote

I tried adding the code below ( inside 100-OPEN) to an existing DB2 program in order to eliminate -501s using the pattern in an IBM manual which uses "predicate' for the call: It fails at compile time with
IGYPS2121-S "READCUR" was not defined as a data-name.
But READCUR is defined in WS:
EXEC SQL
DECLARE READCUR CURSOR FOR
SELECT etc. etc.
Wondering if I can't use DB2 predicates for some reason ?

Code:
100-OPEN.
IF READCUR IS OPEN
EXEC SQL
CLOSE READCUR
END-EXEC
EXEC SQL
OPEN READCUR
END-EXEC
ELSE
EXEC SQL
OPEN READCUR
END-EXEC
END-IF
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 2573
Location: NYC,USA

PostPosted: Fri May 19, 2017 10:04 pm
Reply with quote

Do you know about cursor WITH HOLD option?
Why do you want to code around-501?

Quote:
IF READCUR IS OPEN
This is not true you need to check SQLCODE against -501 in IF condition.
like
step1- open cursor
step2 - if <the cursor is already open> then check SQLCODE against -502 and do else do something end
Back to top
View user's profile Send private message
John F Dutcher

New User


Joined: 02 Apr 2008
Posts: 11
Location: Harrisburg, PA

PostPosted: Fri May 19, 2017 10:11 pm
Reply with quote

but my employer wants to prevent -501s and -502s..... not code logically in response to them. Why did you say "This is not true..." What is it that is not true " ?
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 2573
Location: NYC,USA

PostPosted: Fri May 19, 2017 10:16 pm
Reply with quote

Quote:
but my employer wants to prevent -501s and -502s
At first place one should not code around this sqlcode because the moment you are coding this means your programming logic is messed up badly and that needs to be fixed as ideally one should get these SQLCODES.
second "IF READCUR IS OPEN" this is not a valid COBOL sentence, it should only "IF READCUR IS TRUE" where you got to set READCUR when you get -501/-502.
Back to top
View user's profile Send private message
John F Dutcher

New User


Joined: 02 Apr 2008
Posts: 11
Location: Harrisburg, PA

PostPosted: Fri May 19, 2017 10:34 pm
Reply with quote

.... but the "OPEN" is taken from IBM's Manual on using DB2 predicates so I would think it would be right ..........
Back to top
View user's profile Send private message
John F Dutcher

New User


Joined: 02 Apr 2008
Posts: 11
Location: Harrisburg, PA

PostPosted: Fri May 19, 2017 10:39 pm
Reply with quote

........ so it just seems as though my COBOL or DB2 environment doesn't tolerate predicate usage.........although I admit throwing a '14' return code at compile time and saying that READCUR is undefined seems a weird way to make that point.
Back to top
View user's profile Send private message
prino
Warnings : 1

Senior Member


Joined: 07 Feb 2009
Posts: 1241
Location: Vilnius, Lithuania

PostPosted: Sat May 20, 2017 12:16 am
Reply with quote

John F Dutcher wrote:
but my employer wants to prevent -501s and -502s..... not code logically in response to them.

And next thing, they don't want to see +100 anymore...

Sheesh, DB2 generates these codes for a reason, why the flucking hell bend yourself backwards to avoid them?

Or is your employer in the business of cleaning fans?
Back to top
View user's profile Send private message
John F Dutcher

New User


Joined: 02 Apr 2008
Posts: 11
Location: Harrisburg, PA

PostPosted: Sat May 20, 2017 12:39 am
Reply with quote

.....that's what we do !!!

All that said...... I gather all agree...trying to test the state of the cursor
with DB2 predicates is not likely doable........ despite IBM manuals.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 2573
Location: NYC,USA

PostPosted: Tue May 23, 2017 8:49 pm
Reply with quote

Quote:
........ so it just seems as though my COBOL or DB2 environment doesn't tolerate predicate usage.........although I admit throwing a '14' return code at compile time and saying that READCUR is undefined seems a weird way to make that point.
You are mixing COBOL and SQL statements. You need to clearly able to differentiate them. What you coded is in COBOL and not under "EXEC SQL" so you will get compilation errors and the reason is in my previous post.
Quote:
.... but the "OPEN" is taken from IBM's Manual on using DB2 predicates so I would think it would be right ..........
Please point us to the manual that said so.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts FILE STATUS - 39 ON VARIABLE LENGTH V... COBOL Programming 2
No new posts Is SQLCODE -811 possible while fetchi... DB2 1
No new posts Restart logic by using cursor name in... DB2 1
No new posts Seeking Resolution for SQKCODE -991 o... DB2 2
No new posts Multiple rows within Cursor when Coun... DB2 14
Search our Forums:

Back to Top