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;
/

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 ................................

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.