|
View previous topic :: View next topic
|
| Author |
Message |
kussu Warnings : 1 New User

Joined: 16 May 2007 Posts: 33 Location: India
|
|
|
|
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 |
|
 |
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
| Cursors do not go into infinite loops, but programs do, what is the logic of the "FETCH UNTIL DATA NOT FOUND"? |
|
| Back to top |
|
 |
kussu Warnings : 1 New User

Joined: 16 May 2007 Posts: 33 Location: India
|
|
|
|
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 |
|
 |
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
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 |
|
 |
hariibm
New User
Joined: 05 Feb 2007 Posts: 61 Location: Chennai
|
|
|
|
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 |
|
 |
kussu Warnings : 1 New User

Joined: 16 May 2007 Posts: 33 Location: India
|
|
|
|
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 Row1Before 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 |
|
 |
hariibm
New User
Joined: 05 Feb 2007 Posts: 61 Location: Chennai
|
|
|
|
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 |
|
 |
kussu Warnings : 1 New User

Joined: 16 May 2007 Posts: 33 Location: India
|
|
|
|
Its not related to only one value........
I just mentioned an example there ........
like that so many are there |
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
What does your FETCH look like?
Does it by chance mention CURRENT? |
|
| Back to top |
|
 |
|
|