|
-
Go to Next Record in For Loop
I want to know how to go to the next record in a for loop if a column in a record equals a certain value. For example
declare
cursor c1 is
select * from mytable;
begin
for v1 inc1 loop
if v1.mycolumn = 'A' then
< here is where I want to tell it to go to the next record >
end if;
v1.mycolumn = 'R';
end loop;
end;
/
Can I use some type of break command.
-
Forms? next_record
You could also do null (if a=b then null) to do nothing (assuming nothing else is processed). You could use goto, but that isn't usually recommended. You could use WHILE instead of what you have now.
When you want to go to the next record, while using a loop, let the loop control structure call the next record for you. So in your example, do nothing ("null;").
select * for a cursor - do you really need to select every column from a table? That is lazy. And what happens when a=b? Do you need to stop the loop, or continue to evaluate each record?
Last edited by stecal; 06-09-2003 at 02:10 PM.
-
I guess I'm missing the point here, but why not:
Code:
DECLARE
CURSOR c1 IS
SELECT * FROM mytable
WHERE myColumn <> 'A'
Jeff Hunter
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|