How to exit from a For Loop on a cursor correctly [message #517375] |
Mon, 25 July 2011 11:08  |
ncsthbell
Messages: 10 Registered: September 2010 Location: North Carolina
|
Junior Member |
|
|
I would like to exit from a cursor loop based on certain conditional checking. I am checking for a lot of different parameters and if they fail, I want to bypass it and fetch the next record in the cursor. I tried just putting an 'Exit' statement in the logic, but it fails. An example of my code is below:
For Row1 in cursor1
Loop
If amount < 0 then
balance := 0;
Else
-- need to get the next cursor row
end if
If tx_credit < 0
credit = 0;
Else
-- need to get the next cursor row
End if
--Did not include all of my 'if' statements in this sample
End Loop;
|
|
|
|
|
Re: How to exit from a For Loop on a cursor correctly [message #517391 is a reply to message #517389] |
Mon, 25 July 2011 12:11   |
ncsthbell
Messages: 10 Registered: September 2010 Location: North Carolina
|
Junior Member |
|
|
My problem is that the 'Exit' is taking me out of the cursor loop, I want to get the next record in the cursor.
I have put the conditions on the where clause for the cursor as best I can. However, there is some very complicated conditional checking that is not easily done in the 'where' clause, therefore I am coding it as conditional checks.
The sample I put in this post is the basic sample of what I am trying to do, I did not include all of the conditional 'If, else, then' code. The column names I mentioned would be obtained through the cursor.
|
|
|
|
|
|
|
|