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

Problem in FETCH


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

New User


Joined: 22 Aug 2009
Posts: 4
Location: Chennai

PostPosted: Sat Aug 22, 2009 6:41 am
Reply with quote

Hi,

I am trying to fetch a column from a table using a cursor. But the query returns SQL -100 for the first time it fetches. When the program starts processing the next record, and inputs the next record's data into the WHERE clause, the data for the previous record gets fetched.

So i wrote OPEN,FETCH, CLOSE CURSOR steps twice in the program as shown
1) OPEN CURSOR
2) FETCH CURSOR
3) CLOSE CURSOR
4) OPEN CURSOR
5) FETCH CURSOR
6) CLOSE CURSOR

The same input is not giving output in step2 but gives output in step 5. Closing and opening the cursor makes corrects the issue, but i am not sure how this happens. Can somebody help me on this
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


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

PostPosted: Sat Aug 22, 2009 6:51 am
Reply with quote

No one can help given the information you've provided. We need to see a dump of the fetched row using SPUFI or whatever and all of your code relevant to the table including the DCLGEN, the cursor declaration, and all of your SQL for the OPEN and FETCH. Display the host variables immediately before each FETCH and all SQLCODEs after any SQL.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Sat Aug 22, 2009 7:39 am
Reply with quote

Hello and welceom to the forum,

What is the sqlcode after the open?

Please include this when posting the other requested info. . .
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 Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts Fetch data from programs execute (dat... DB2 3
No new posts Code Multi Row fetch in PL1 program PL/I & Assembler 1
No new posts Need to fetch data from so many DB2 t... DB2 9
No new posts z/vm installation problem All Other Mainframe Topics 0
Search our Forums:

Back to Top