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 With Modification of Cursor

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
kussu
Warnings : 1

New User


Joined: 16 May 2007
Posts: 33
Location: India

PostPosted: Fri Aug 10, 2007 1:05 pm    Post subject: Problem With Modification of Cursor
Reply with quote

I am modifying one cursor so as to meet my requirement

Cursor looks like

BLUE :- Already existing
GREEN: - New Condition inserted for my requirement


EXEC SQL
DECLARE CUR1 CURSOR FOR
SELECT ………………,
………………
FROM TAB1
WHERE Tables column1 effective date <=
Starting date
AND Tables colmn2 expired date >=
End date
OR (Tables column1 effective date >=
Starting date
AND Tables column1 effective date <=
End date)
ORDER BY 1 ASC
WITH UR
END-EXEC.

And while fetching this cursor, the system is checking the condition as[Existing condition] FETCH UNTIL DATA NOT FOUND.

But While processing, when the system is executing my condition it is going into infinite loop, like it is executing the same row always........

For every time, DATA FOUND switch is setting and its keep on continuing that only……….

My Question is why for that condition only the cursor is going to infinite loop ???????????
What is the wrong in that??? I am not at getting
Back to top
View user's profile Send private message

William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Fri Aug 10, 2007 2:14 pm    Post subject:
Reply with quote

Cursors do not go into infinite loops, but programs do, what is the logic of the "FETCH UNTIL DATA NOT FOUND"?
Back to top
View user's profile Send private message
kussu
Warnings : 1

New User


Joined: 16 May 2007
Posts: 33
Location: India

PostPosted: Fri Aug 10, 2007 2:29 pm    Post subject: Re: Problem With Modification of Cursor
Reply with quote

It will fetch that above mentioned cursor until the data not found condition is satisfied.

But in my case.......,
For the first fetch, it is executing this condtion and as the condition is satisfied , i am setting one switch.
And for the second fetch also it is executing that query for same dates, and for this also the condition is satisfied ......

The values i have for these dates is as .....

Tables column1 effective date :- 2003/oct/01
Tables colmn2 expired date :- 9999/dec/31
Starting date :- 2003/sep/29
End date :- 2003/oct/27

So, in table i had 2 rows, and according to the condition which i had mentioned it is fetching the 1st row, and upto this it was correct only

but for the remaining fetches also, it is fetching the same first row and continuing like that...........as never ending process.

i am not getting what is the problem in my condition
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Fri Aug 10, 2007 2:44 pm    Post subject:
Reply with quote

Debugging mode....
How can you setup a select for a cursor on a finite table that will return an infinite number of identical rows?
Back to top
View user's profile Send private message
hariibm

New User


Joined: 05 Feb 2007
Posts: 61
Location: Chennai

PostPosted: Fri Aug 10, 2007 2:46 pm    Post subject: Re: Problem With Modification of Cursor
Reply with quote

since both the conditions seem to be of mutually exclusive, the cursor will have all the rows of the table and thus seem that it is going infinite loop.
Please correct me if I am wrong.
Back to top
View user's profile Send private message
kussu
Warnings : 1

New User


Joined: 16 May 2007
Posts: 33
Location: India

PostPosted: Fri Aug 10, 2007 3:14 pm    Post subject: Re: Problem With Modification of Cursor
Reply with quote

William,

That is a finite table……….
As per the system, based on some other conditions, this table will have only these two rows,

And this table values are like

First Row:-
Tables column1 effective date 2003-oct-01
Tables colmn2 expired date 9999-Dec-31
Column3 Sas1

Second Row:-
Tables column1 effective date 1998-Aug-19
Tables colmn2 expired date 2003-Sep-30
Column3 Sas2

Starting date :- 2003/sep/29
End date :- 2003/oct/27

Starting date has the value which is falling under the range of Row2
End date has the value which is falling under the range of Row1
Before updation, the value I had is Sas2, and this value will be assigned in the system based on the above mentioned cursor only.

And now , I have to modify all the values which are fallen under the criteria[Which I mentioned here in blue] like this, to Sas1 instead of Sas2.

Then how I need to modify that cursor.

And Hari,

I am also thinking both the conditions are mutually exclusive only
So I am thinking to check with another condition…but I don’t know how to place that condition.
Back to top
View user's profile Send private message
hariibm

New User


Joined: 05 Feb 2007
Posts: 61
Location: Chennai

PostPosted: Fri Aug 10, 2007 4:00 pm    Post subject: Re: Problem With Modification of Cursor
Reply with quote

since your idea is to update all the rows with sas1, then why don't you write an update SQL and update all the rows?

Regards,
Hari.
Back to top
View user's profile Send private message
kussu
Warnings : 1

New User


Joined: 16 May 2007
Posts: 33
Location: India

PostPosted: Fri Aug 10, 2007 4:38 pm    Post subject: Re: Problem With Modification of Cursor
Reply with quote

Its not related to only one value........
I just mentioned an example there ........

like that so many are there
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: Fri Aug 10, 2007 7:06 pm    Post subject:
Reply with quote

Hello,

What does your FETCH look like?

Does it by chance mention CURRENT?
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 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 Release of Adabas Cursor mohitsethi All Other Mainframe Topics 1 Mon Feb 06, 2017 8:36 pm
No new posts SYMNAMES problem jacobdng DFSORT/ICETOOL 7 Thu Dec 22, 2016 7:47 am


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