| jayesh |
Posted: Jan 11, 2008 08:19:57 AM |
Total Post: 60
Joined: Jan, 2008
|
I m trying to create a procedure to get all numbers divisible by the parameter number. all divisible numbers should be 1...100
logic i used is
create or replace procedure sp_div_num
(p_num number) is
i number;
begin
i:=1;
for loop i in 1...100
if mod(i,p_num)=0 then
dbms_output.put_line(i)
i:=i+1
end if;
end loop;
end sp_div;
/
when i m executing this like
execute sp_div(5)
each and everytime oracle gets hanged and i m getting my 'not responding'
Can anybody help me out its urget for me.
|
|
|
Murtuja |
| Posted: Jan 11, 2008 09:40:09 AM | |
|
Total Post: 814
Joined: Jan, 2006
|
create or replace procedure sp_div_num
(p_num number) is
i number;
begin
i:=1;
for loop i in 1...100
if mod(i,p_num)=0 then
dbms_output.put_line(i)
end if;
i:=i+1;
end loop;
end sp_div;
/
you have put increment inside if block so
|
|
|
|
|
jayesh |
| Posted: Jan 11, 2008 09:49:03 AM | |
|
Total Post: 60
Joined: Jan, 2008
|
|
|
|
|
lavu |
| Posted: Jan 13, 2008 11:12:16 PM | |
|
Total Post: 3
Joined: Jan, 2008
|
hi Jayesh,
if u do like this it will execute
if u r using for loop it is necessary to increment the value of i
automatically it increments to 1.
other than 1 we cannot increment in for loop.
create or replace procedure sp_div_num
(p_num number) is
i number;
begin
for i in 1..100 LOOP
if mod(i,p_num)=0 then
dbms_output.put_line(i);
end if;
end loop;
end sp_div_NUM;
|
|
|
|
|
| Time Zone: EDT |
Send this thread to your friend |