loops&cursors [message #437] |
Tue, 12 February 2002 02:02 |
ratna
Messages: 7 Registered: October 2001
|
Junior Member |
|
|
hi!,I am new to ORACLE.I was trying with loop to get all prime numbers,but could not do.
How can I do it with loop.
I created a Table messages with one field(results) and then tried to view the result.
I am also not getting clear with loops,cursors.
where can i view examples to get myself clear.
Thanks in advance.
|
|
|
Re: loops&cursors [message #438 is a reply to message #437] |
Tue, 12 February 2002 02:35 |
pratap kumar tripathy
Messages: 660 Registered: January 2002
|
Senior Member |
|
|
here is an example ..try and see(it display all prime numbers between 2 and 100
set serveroutput on
declare
begin
for i in 2..100
loop
for j in 2..trunc(sqrt(i))
loop
if mod(i,j)=0 then goto c; end if;
end loop;
dbms_output.put_line(to_char(i));
<<c>> null;
end loop;
end;
|
|
|
|
Re: loops&cursors [message #1751 is a reply to message #437] |
Sun, 26 May 2002 17:26 |
Stephanie
Messages: 5 Registered: March 2002
|
Junior Member |
|
|
is there another way of doing a loop for prime numbers besides taking the square root? No other easier way. Because I have to do prime numbers form 10000 to 10100
|
|
|