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

Cursor retrieving same data all the time


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

New User


Joined: 16 Feb 2007
Posts: 2
Location: Markapur

PostPosted: Wed Mar 11, 2009 12:45 am
Reply with quote

Hi, I have declare a DEPOSIT-CURSOR in my program where i will read account number from file and get the sum of deposit balance by fetching and summing up deposit balance from cursor. The problem i am facing is the cursor is retrieving data correctly for the first account from the file. starting from second account number it is returning same rows as of the first account. appreciate help and ideas.
Back to top
View user's profile Send private message
murugan_mf

Active User


Joined: 31 Jan 2008
Posts: 148
Location: Chennai, India

PostPosted: Wed Mar 11, 2009 12:58 am
Reply with quote

My guess is May be you are not reading the file inside fetch cursor loop..

Helpful if you post the portion of your code
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: Wed Mar 11, 2009 1:31 am
Reply with quote

Hello and welcome to the forum,

Is the cursor defined for one account number?

Did you close and open the cursor when account number changes?
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Wed Mar 11, 2009 1:35 am
Reply with quote

If there is a host variable in your where clause and it changes then you must close and open the cursor again
Back to top
View user's profile Send private message
rajeshps19

New User


Joined: 14 Feb 2007
Posts: 4
Location: Noida

PostPosted: Wed Mar 11, 2009 2:55 am
Reply with quote

Hi Naresh,

As per my understanding you are reading account-no from file and then getting the related data thru cursor. Since u are using cursor, the account-no host variable should be populated with new values from file before opening the cursor again. You should also close the cursor once u retrieve data for one acct-no. Then again open the cursor for next acct-no. If u don't close the cursor then it will retrieve the same data as previous due to the cursor pointing to the previous record.

Thanks,
Rajesh.
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 Store the data for fixed length COBOL Programming 1
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts SCOPE PENDING option -check data DB2 2
No new posts To get the the current time DFSORT/ICETOOL 13
No new posts RC query -Time column CA Products 3
Search our Forums:

Back to Top