Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> How to exit a procedure if condition is true
I have a procedure that I need to jump out of if a variable is null.
Should I use an exception, and if so what is the syntax for exiting
the procedure? I know I can't use "exit" unless I'm in a loop - I'm
stumped!
create or replace procedure proc_cleanup
is
begin
DECLARE
v_id integer; v_quantity integer;
cursor v_cursor is
select id_no, quantity
from table1;
BEGIN
open v_cursor;
--fetch first recordset to get initial values
fetch v_cursor into v_id, v_quantity;
---****
--insert the fetched values into table2
insert into table2 values(v_id, v_quantity);
--loop through the remaining records and insert until finished
loop
fetch v_cursor into v_id, v_quantity;
exit when v_cursor%notfound;
insert into table2 values(v_id, v_quantity);
end loop;
close v_cursor;
END;
end proc_cleanup;
Received on Tue May 06 2003 - 16:49:21 CDT