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 FETCH

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Problem in FETCH
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    Post subject:
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

Site Director


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

PostPosted: Sat Aug 22, 2009 7:39 am    Post subject:
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    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 Problem reading GTF trace output danik56 ABENDS & Debugging 7 Thu Mar 16, 2017 1:02 pm
No new posts ROUNDED Problem with COMPUTE statement shalem COBOL Programming 11 Thu Feb 09, 2017 8:16 pm
No new posts SYMNAMES problem jacobdng DFSORT/ICETOOL 7 Thu Dec 22, 2016 7:47 am
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm
No new posts Problem in Running Query via JCL vickey_dw DB2 3 Tue Oct 18, 2016 11:11 pm


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