Home » SQL & PL/SQL » SQL & PL/SQL » loop
loop [message #36583] Wed, 05 December 2001 09:10 Go to next message
ghazala
Messages: 6
Registered: December 2001
Junior Member
i wanna make a loop 1 to 100, which should remain continue, circulating between 1 and 100, the loop should break at some specified point in time say after 60 secs.
how could i design the loop and the timer.

----------------------------------------------------------------------
Re: loop [message #36585 is a reply to message #36583] Wed, 05 December 2001 09:27 Go to previous messageGo to next message
Suresh Vemulapalli
Messages: 624
Registered: August 2000
Senior Member
declare
ldate date:=sysdate;
i number(10):=0;
begin
loop
IF ((i>100) or ((sysdate-ldate)>=1/1440)) then
exit;
end if;
i:=i+1;
end loop;
dbms_output.put_line(i);
end;

----------------------------------------------------------------------
Re: loop [message #36589 is a reply to message #36583] Wed, 05 December 2001 10:47 Go to previous messageGo to next message
ghazala
Messages: 6
Registered: December 2001
Junior Member
dear suresh,
glad to receive your very quick response to my ever first querry.
your suggestion returns the answer 101.
let me be more clear to u.
i wanna a design a form, like a "lucky draw"
having a text item "draw# number(7)" and a display item "timer".
on pressing the push button the trigger "when_ button_pressed" should start the loop, which would not exit i.e it should only break when my timer will complete 60 seconds. and the timer should also start when the push button will be pressed simultaneously when the loop starts.
guide me to design a running timer on my form too.
thanks.
hope to read u one more time.

----------------------------------------------------------------------
Re: loop [message #36592 is a reply to message #36583] Wed, 05 December 2001 11:35 Go to previous messageGo to next message
Suresh Vemulapalli
Messages: 624
Registered: August 2000
Senior Member
if you are working on forms, there is timer option. when you click on when_button_pressed button start timer and set expire time to 60 secs.
when ever timer expires oracle fires when-timer-expired trigger.

HTH
SURESH

----------------------------------------------------------------------
Re: loop [message #36595 is a reply to message #36583] Wed, 05 December 2001 11:46 Go to previous messageGo to next message
ghazala
Messages: 6
Registered: December 2001
Junior Member
dear suresh,
thank u once again.
help me find out that timer option on my form.

----------------------------------------------------------------------
Re: loop [message #36607 is a reply to message #36592] Thu, 06 December 2001 03:45 Go to previous messageGo to next message
Suresh Vemulapalli
Messages: 624
Registered: August 2000
Senior Member
create timer programatically using

n:= CREATE_TIMER('mytimer',60000,no_repeat);

(write above statement in when_button_pressed trigger)

create trigger (when-timer-expired) at form level . Write code what ever you want to execute when timer expires.

SURESH

----------------------------------------------------------------------
Re: loop [message #36611 is a reply to message #36592] Thu, 06 December 2001 04:36 Go to previous message
Suresh Vemulapalli
Messages: 624
Registered: August 2000
Senior Member
create timer programatically using
n:= CREATE_TIMER('mytimer',60000,no_repeat);

(write above statement in when_button_pressed trigger)

create trigger (when-timer-expired) at form level . Write code what ever you want to execute when timer expires.

SURESH

----------------------------------------------------------------------
Previous Topic: passing more than 2 parameters to an cursor
Next Topic: using inline subquery in a PL/SQL cursor
Goto Forum:
  


Current Time: Fri Aug 14 15:43:43 CDT 2020