Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Testing rerad cursor for status with predicate

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
John F Dutcher

New User


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

PostPosted: Fri May 19, 2017 9:35 pm    Post subject: Testing rerad cursor for status with predicate
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

Senior Member


Joined: 21 Sep 2010
Posts: 1696
Location: NY,USA

PostPosted: Fri May 19, 2017 10:04 pm    Post subject:
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: 9
Location: Harrisburg, PA

PostPosted: Fri May 19, 2017 10:11 pm    Post subject: Understood .........
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

Senior Member


Joined: 21 Sep 2010
Posts: 1696
Location: NY,USA

PostPosted: Fri May 19, 2017 10:16 pm    Post subject:
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: 9
Location: Harrisburg, PA

PostPosted: Fri May 19, 2017 10:34 pm    Post subject: I'll try "true" for grins........
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: 9
Location: Harrisburg, PA

PostPosted: Fri May 19, 2017 10:39 pm    Post subject: H-m-m using "TRUE" gives same result
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

Senior Member


Joined: 07 Feb 2009
Posts: 1018
Location: Oostende, Belgium

PostPosted: Sat May 20, 2017 12:16 am    Post subject: Re: Understood .........
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: 9
Location: Harrisburg, PA

PostPosted: Sat May 20, 2017 12:39 am    Post subject: You guessed it.......... !!!!
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

Senior Member


Joined: 21 Sep 2010
Posts: 1696
Location: NY,USA

PostPosted: Tue May 23, 2017 8:49 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Getting -504 Cursor Name GTT-ARTS-CUR... Robin Sulsona DB2 2 Fri Mar 17, 2017 1:43 am
No new posts Release of Adabas Cursor mohitsethi All Other Mainframe Topics 1 Mon Feb 06, 2017 8:36 pm
This topic is locked: you cannot edit posts or make replies. session stuck in TPX with status ACL amitc23 CA Products 1 Tue Dec 13, 2016 12:53 pm
No new posts Updating Cursor row withour using FOR... chandan.inst DB2 15 Tue Nov 08, 2016 11:17 am
No new posts Variable for cursor names ravikumar15 DB2 5 Sun Jul 17, 2016 7:08 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us