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
 

 

problem in setting end-of-cursor-yes

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
sm_2009

New User


Joined: 10 May 2009
Posts: 72
Location: bangalore

PostPosted: Mon Jun 08, 2009 11:34 am    Post subject: problem in setting end-of-cursor-yes
Reply with quote

hi all,

i have a requirement as follows:

1. the cursor will fetch rows from a table taking few fields as key.
2. i have to check the year part of date(fetched from table) with input date year part.
3. if both the years are matching i need to add amounts fields (fethced from table)

the problem is I'm using cursor to fetch data from table.
I'm not getting where i will set end-of-cursor-yes as true.
Back to top
View user's profile Send private message

sm_2009

New User


Joined: 10 May 2009
Posts: 72
Location: bangalore

PostPosted: Mon Jun 08, 2009 2:10 pm    Post subject:
Reply with quote

pls suggest
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Jun 08, 2009 2:13 pm    Post subject:
Reply with quote

When your SQLCODE is not 000 after a FETCH.
A +100 is a normal out-of-data/end-of-data condition.
Any negative SQLCODE indicates that you have a problem.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Mon Jun 08, 2009 2:14 pm    Post subject: Reply to: problem in setting end-of-cursor-yes
Reply with quote

please do not pester icon_evil.gif

replying is on voluntary base, effort, time, interest

look at the relevant db2 manuals for the return code issued bt SQL when no more rows are avilable to fetched
Back to top
View user's profile Send private message
aishwarya_20

New User


Joined: 19 Nov 2008
Posts: 57
Location: pune

PostPosted: Mon Jun 08, 2009 2:15 pm    Post subject:
Reply with quote

You need to check SQLCODE each time you fetch from the cursor. End of cursor will be set when SQLCODE returned after fetch query is +100.
Else if fetch call is successfull SQLCODE will be zero.
Back to top
View user's profile Send private message
sm_2009

New User


Joined: 10 May 2009
Posts: 72
Location: bangalore

PostPosted: Mon Jun 08, 2009 2:30 pm    Post subject:
Reply with quote

hi all
thanks

table has two rows with values 100.00 and 200.00

pgm:

set end-of-cursor-no to true
open cursor
fetch cursor
evaluate sqlcode
when 0
perform 123-add-para
when 100
set end-of-cursor-yes to true
when other
call error-para
end-evaluate
close cursor

123-add-para.
compute ws-total=ws-total + ws-val


ws-val is fetch amount from table.
here only first row is getting fetched and addition is not happening.

pls suggest solution
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Mon Jun 08, 2009 2:32 pm    Post subject: Reply to: problem in setting end-of-cursor-yes
Reply with quote

do You realize that You must implement a loop to fetch all the rows ??
Back to top
View user's profile Send private message
sm_2009

New User


Joined: 10 May 2009
Posts: 72
Location: bangalore

PostPosted: Mon Jun 08, 2009 2:34 pm    Post subject:
Reply with quote

ok

then

i can write as perform 123-add-para until end-of-cursor-yes
after the query?
Back to top
View user's profile Send private message
sm_2009

New User


Joined: 10 May 2009
Posts: 72
Location: bangalore

PostPosted: Mon Jun 08, 2009 2:42 pm    Post subject:
Reply with quote

now the whole add-para is going in loop

icon_sad.gif
Back to top
View user's profile Send private message
sm_2009

New User


Joined: 10 May 2009
Posts: 72
Location: bangalore

PostPosted: Mon Jun 08, 2009 3:28 pm    Post subject:
Reply with quote

i have put perform fetch para until end-of-cursor-yes

when sqlcode = 0, perform 123-add-para

still amts are not adding up.
Back to top
View user's profile Send private message
sm_2009

New User


Joined: 10 May 2009
Posts: 72
Location: bangalore

PostPosted: Mon Jun 08, 2009 5:14 pm    Post subject: issue resolved
Reply with quote

issue resolved
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1238
Location: Richfield, MN, USA

PostPosted: Mon Jun 08, 2009 5:32 pm    Post subject:
Reply with quote

Please share your solution for the benefit of others.
Back to top
View user's profile Send private message
sm_2009

New User


Joined: 10 May 2009
Posts: 72
Location: bangalore

PostPosted: Mon Jun 08, 2009 6:43 pm    Post subject:
Reply with quote

the looping is like this:

perform fetch para until end-of-cursor

close cursor

if end-of-cursor-yes
display 'no more amts'
end-if

fetch -para.

set end-of-cursor-no to true

open cursor

fetch data from table
evaluate sqlcode
when sqlcode = 0
perform 123-add-para
when 100
set end-of-cursor-yes to true
when other
call error para
end-evaluate

123-add-para.

compute ws-total = ws-total + ws-val(from table)
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1238
Location: Richfield, MN, USA

PostPosted: Mon Jun 08, 2009 7:48 pm    Post subject:
Reply with quote

Are you sure what you coded works? I think the first 2 statements inside your fetch para should not be where they are now but rather should be placed right before the "perform fetch para entil end-of-cursor" statement.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue Jun 09, 2009 4:24 am    Post subject:
Reply with quote

Hello,

Quote:
Are you sure what you coded works?
I suspect it does not. . .
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 -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm
No new posts Updating Cursor row withour using FOR... chandan.inst DB2 15 Tue Nov 08, 2016 11:17 am
No new posts Problem in Running Query via JCL vickey_dw DB2 3 Tue Oct 18, 2016 11:11 pm
No new posts DB2 Streaming Batch Processing Problem Manshadi DB2 4 Sat Sep 24, 2016 12:14 pm
No new posts Problem with GETMAIN command amitc23 CICS 6 Thu Sep 01, 2016 1:01 pm


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