Hi, I m a beginner, pls how can I exit this Loop.
LOOP
update Table1 set name = 'xxx'
where number LIKE '1%';
END LOOP;
I want to update some rows and exit this loop when all rows are updated.
Thanks
Hi, I m a beginner, pls how can I exit this Loop.
LOOP
update Table1 set name = 'xxx'
where number LIKE '1%';
END LOOP;
I want to update some rows and exit this loop when all rows are updated.
Thanks
the follow is the syntax for loop
LOOP
;
EXIT WHEN
;
END LOOP;
u just need to add exit when with some condition
But tell me first to update why need a loop. while u can do the same by a simple DML ???
use :
my question is why you want loop concept ? ,just update the '1%' records.
whether you want other purpose means use
declare
n number;
i number default 1;
begin
select count(*) from table1 where number like '1%';
loop
update Table1 set name = 'xxx' where number LIKE '1%';
i=:i+1;
exit when i>=n
end;
by Sekar.S
loop is used to repeatedly execute a certain statment till a certain condition is acchieved.
U can use cursors more effectively for this purpose.U can use %notfound attribute of cursor to break the loop like
loop
update...
exit when cursorname%notfound
end loop;
use this condition
EXIT WHEN SQL%NOTFOUND