0

Hello guys,

Just need to know - wats making oracle to stuck when i run this simple pl-sql module

declare
counter number;
begin
<<outer>>
for counter in 1..10 loop

<<inner>>
loop
insert into lines
values(counter);
exit when counter=6 or counter=8;
end loop inner;
end loop outer;
end;
/

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by like_to_learn
0

you need to write exit condition for outloop.and one more thing,you need to Decrement the counter value in inner loop ,otherwise it will run for infinite times........................Fist of all you just avoid lables,it will degrade the performance.............................
you can run below code to run this for one time likewise you need to give conditions to terminate loop...........................

declare
counter number;
begin
<<outer>>
for counter in 1..10 loop

<<inner>>

loop
insert into lines
values(counter);
dbms_output.put_line(counter);

exit when counter=1 or counter=8;
end loop inner;
exit when counter=1 or counter=8;
end loop outer;
end;
/
One more thing,what is the need of that condition,counter=1 or counter=8; this or condition is no need,unless if you give the numbers dynamically..................

I think this will help you ................................

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.