Home » Developer & Programmer » Forms » Delay in loop
icon2.gif  Delay in loop [message #211056] Mon, 25 December 2006 23:19 Go to next message
myclassic
Messages: 136
Registered: December 2006
Location: Pakistan
Senior Member
i want to display numbers from 1..100 and there must be delay in displaying each number. i want to add delay in loop. help required in oracle ..form..
Re: Delay in loop [message #211184 is a reply to message #211056] Wed, 27 December 2006 01:33 Go to previous messageGo to next message
wency
Messages: 450
Registered: April 2006
Location: Philippines
Senior Member

If you want manual delay, then insert this:
For x IN 1..1000
          Loop
             NULL;
          End Loop;
Re: Delay in loop [message #211306 is a reply to message #211184] Wed, 27 December 2006 21:56 Go to previous messageGo to next message
myclassic
Messages: 136
Registered: December 2006
Location: Pakistan
Senior Member
thanks dear u replied my question. yes this is a way but it looks some what improper. but suggest some proper way to insert delay in loop.
Re: Delay in loop [message #211322 is a reply to message #211056] Wed, 27 December 2006 23:58 Go to previous messageGo to next message
wency
Messages: 450
Registered: April 2006
Location: Philippines
Senior Member

Delay is maybe loop or timer. Try to use timer if you want, but I prefer loop for it's simplicity.
Re: Delay in loop [message #211334 is a reply to message #211322] Thu, 28 December 2006 00:32 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
You asked this question in the Forms forum, so this doesn't necessarily have to be helpful to you, but nevertheless: DBMS_LOCK package could be used for this purpose:
SQL> begin
  2    for i in 1 .. 5
  3    loop
  4      dbms_output.put_line(to_char(sysdate, 'mi:ss'));
  5      dbms_lock.sleep(3);
  6    end loop;
  7  end;
  8  /
27:40
27:43
27:46
27:49
27:52

PL/SQL procedure successfully completed.

SQL>
Re: Delay in loop [message #212116 is a reply to message #211334] Wed, 03 January 2007 18:03 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Have you solved your problem?

Have you considered using a 'timer'? Search the reference manual and this forum for 'timer' to get more ideas.

David
Re: Delay in loop [message #212119 is a reply to message #211184] Wed, 03 January 2007 18:36 Go to previous messageGo to next message
William Robertson
Messages: 1643
Registered: August 2003
Location: London, UK
Senior Member
wency wrote on Wed, 27 December 2006 01:33
If you want manual delay, then insert this:
For x IN 1..1000
          Loop
             NULL;
          End Loop;


Won't that just burn up all the CPU available? Isn't that kind of a bad idea?
Re: Delay in loop [message #212120 is a reply to message #211056] Wed, 03 January 2007 18:51 Go to previous messageGo to next message
wency
Messages: 450
Registered: April 2006
Location: Philippines
Senior Member

In my experience, it won't.
Re: Delay in loop [message #212210 is a reply to message #212120] Thu, 04 January 2007 04:32 Go to previous messageGo to next message
William Robertson
Messages: 1643
Registered: August 2003
Location: London, UK
Senior Member
In my experience, and Tom Kyte's, it will.
http://oracle-wtf.blogspot.com/2006/10/pause-for-thought-part-2.html
Re: Delay in loop [message #212352 is a reply to message #211056] Thu, 04 January 2007 20:23 Go to previous messageGo to next message
wency
Messages: 450
Registered: April 2006
Location: Philippines
Senior Member

Nice Post!
Thre's a lot on our system. I'm not aware for that 'dbms profiler', we only observe speed.
>>I don't really know whats the reason behind these code.
>>Maybe because we are using the older version, Oracle 5
>>(I'm not sure if dbms_lock is supported)
>>or most probably bacause the requirement is miliseconds delay.

Thanks for that.

Cheers,
Wency

[Updated on: Thu, 04 January 2007 20:52]

Report message to a moderator

Re: Delay in loop [message #212710 is a reply to message #211334] Sun, 07 January 2007 22:06 Go to previous messageGo to next message
myclassic
Messages: 136
Registered: December 2006
Location: Pakistan
Senior Member
thank u wency ... this is really a nice answer so far as sql/plsql is concerned but how will it work in forms.... create a form having a display field and a push button and then execute this ... i shall be thankful to you for this.
Re: Delay in loop [message #212711 is a reply to message #211334] Sun, 07 January 2007 22:10 Go to previous messageGo to next message
myclassic
Messages: 136
Registered: December 2006
Location: Pakistan
Senior Member
thank u littlefoot ... this is really a nice answer so far as sql/plsql is concerned but how will it work in forms.... create a form having a display field and a push button and then execute this ... i shall be thankful to you for this
icon2.gif  Re: Delay in loop [message #212721 is a reply to message #211334] Mon, 08 January 2007 00:04 Go to previous messageGo to next message
myclassic
Messages: 136
Registered: December 2006
Location: Pakistan
Senior Member
SQL> create or replace procedure delay is
2 begin
3 for i in 1 .. 5
4 loop
5 dbms_output.put_line(to_char(sysdate, 'mi:ss'));
6 --dbms_lock.sleep(3);
7 end loop;
8 end delay;
9 /

Procedure created.

It is created if dbms_lock.sleep(3); this commanad is commented but it creates error otherwise.
1 Create or Replace PROCEDURE delay IS
2 BEGIN
3 for i in 1 .. 5
4 loop
5 dbms_output.put_line(to_char(sysdate, 'mi:ss'));
6 dbms_lock.sleep(3);
7 end loop;
8* END delay;
9 /

Warning: Procedure created with compilation errors.
and It also works fine if the procedure is an annonymous block.
1 begin
2 for i in 1 .. 5
3 loop
4 dbms_output.put_line(to_char(sysdate, 'mi:ss'));
5 dbms_lock.sleep(2);
6 end loop;
7* end;
SQL> /
55:28
55:30
55:32
55:34
55:36

PL/SQL procedure successfully completed.

What is the problem and how will it work in form. a form named delay.fmb is attached for further help. please help. i am waiting.
  • Attachment: Delay.fmb
    (Size: 40.00KB, Downloaded 1255 times)
Re: Delay in loop [message #212756 is a reply to message #212721] Mon, 08 January 2007 03:41 Go to previous messageGo to next message
William Robertson
Messages: 1643
Registered: August 2003
Location: London, UK
Senior Member
myclassic wrote on Mon, 08 January 2007 00:04
Warning: Procedure created with compilation errors.

It would save us a lot of guessing if you told us what compilation errors you were getting.

If the procedure is to be a Forms program unit, it will not be efficient to call a server-side package every time it wants to pause 1 second. You would be better looking at a Forms timer as I think someone may have mentioned (I'm afraid I don't have Forms right now and haven't used it for a while).
Re: Delay in loop [message #212788 is a reply to message #212756] Mon, 08 January 2007 06:18 Go to previous messageGo to next message
saadatahmad
Messages: 452
Registered: March 2005
Location: Germany/Paderborn
Senior Member

hi,

I couldn't understand what you were looking for, may be you want to create a digital watch in the form. Anyway, here is your modified form.

Use timers as suggested by William Robertson.

Have a look at the When-New-Form-Instance and When-Timer-Expired trigger code in the form. They're alone doing the trick.

A delay is occurring in populating the value.

regards,
Saadat Ahmad
  • Attachment: Delay.fmb
    (Size: 44.00KB, Downloaded 1403 times)
icon6.gif  Re: Delay in loop [message #212946 is a reply to message #212788] Mon, 08 January 2007 22:02 Go to previous message
myclassic
Messages: 136
Registered: December 2006
Location: Pakistan
Senior Member
Dear saadatahmad
Thanks Sir, I wanted to do this via loop but u have help me in an other way.... thank u really. take care.
Previous Topic: Foreign Function
Next Topic: Open another form
Goto Forum:
  


Current Time: Thu Sep 26 18:18:32 CDT 2024