Thread: waiting in a procedure (urgent)


Permlink Replies: 104 - Pages: 7 [ 1 2 3 4 5 | Next ] - Last Post: Aug 8, 2006 12:47 PM Last Post By: Kamal Kishore
eightten1985@ya...

Posts: 402
Registered: 04/04/05
waiting in a procedure (urgent)
Posted: Jul 8, 2006 10:24 AM
Click to report abuse...   Click to reply to this thread Reply
can i let a procedure wait for a sepcific time( 10 seconds ) before inserting values into a table
Faust - old acc...

Posts: 524
Registered: 01/14/01
Re: waiting in a procedure (urgent)
Posted: Jul 8, 2006 10:30 AM   in response to: eightten1985@ya... in response to: eightten1985@ya...
Click to report abuse...   Click to reply to this thread Reply
yes you can
eightten1985@ya...

Posts: 402
Registered: 04/04/05
Re: waiting in a procedure (urgent)
Posted: Jul 8, 2006 10:38 AM   in response to: Faust - old acc... in response to: Faust - old acc...
Click to report abuse...   Click to reply to this thread Reply
how?
Faust - old acc...

Posts: 524
Registered: 01/14/01
Re: waiting in a procedure (urgent)
Posted: Jul 8, 2006 10:49 AM   in response to: eightten1985@ya... in response to: eightten1985@ya...
Click to report abuse...   Click to reply to this thread Reply
well depending on your requirements and what you exactly want to achieve...

simple example:


faust@XE> declare
...
code censored cause it's "CPU-knackering routine" :-(
 
faust@XE>


Message was edited by:
Faust
Paul M.

Posts: 8,657
Registered: 12/26/02
Re: waiting in a procedure (urgent)
Posted: Jul 8, 2006 11:32 AM   in response to: eightten1985@ya... in response to: eightten1985@ya...
Click to report abuse...   Click to reply to this thread Reply
You can use DBMS_LOCK.SLEEP :

TEST@orcl SQL> get sleep
1 select to_char(sysdate,'hh24:mi:ss') from dual;
2 exec dbms_lock.sleep(10);
3* select to_char(sysdate,'hh24:mi:ss') from dual;
TEST@orcl SQL> @sleep

TO_CHAR(

20:06:08

PL/SQL procedure successfully completed.

TO_CHAR(


20:06:19

TEST@orcl SQL>
William Robertson

Posts: 6,456
Registered: 06/17/98
Re: waiting in a procedure (urgent)
Posted: Jul 8, 2006 3:27 PM   in response to: Faust - old acc... in response to: Faust - old acc...
Click to report abuse...   Click to reply to this thread Reply
> simple example:

Well it was simpler than this one I suppose ;-)
Faust - old acc...

Posts: 524
Registered: 01/14/01
Re: waiting in a procedure (urgent)
Posted: Jul 9, 2006 2:10 AM   in response to: William Robertson in response to: William Robertson
Click to report abuse...   Click to reply to this thread Reply
> simple example:

Well it was simpler than
[url=http://forums.oracle.com/forums/thread.jspa?messa
geID=1360604��]this one[/url] I suppose
;-)

Yes, you are supposing very good ...
;-)

N. Gasparotto

Posts: 18,604
Registered: 08/22/02
Re: waiting in a procedure (urgent)
Posted: Jul 9, 2006 2:24 AM   in response to: Faust - old acc... in response to: Faust - old acc...
Click to report abuse...   Click to reply to this thread Reply
6 lines to manage a loop whereas 1 line is enough...
My mind : I'm a partisan to use what already exists, short code, so the Paul's suggestion seems very good...

Nicolas.
Faust - old acc...

Posts: 524
Registered: 01/14/01
Re: waiting in a procedure (urgent)
Posted: Jul 9, 2006 2:56 AM   in response to: N. Gasparotto in response to: N. Gasparotto
Click to report abuse...   Click to reply to this thread Reply
6 lines to manage a loop whereas 1 line is
enough...

I agree. Do you know story about Master Foo and the Ten Thousand Lines of C code?

My mind : I'm a partisan to use what already exists,
short code, so the Paul's suggestion seems very
good...

I also think that Paul's suggestion is very good.
Did I post something (after his post) against his suggestion for solution?

But yes it's correct that I'm not impressed with ironic humor (sorry William) ...

And one more suggestion :-)

What if Mr. Mohannad Ghawi (who created this thread) has users with restricted privileges (e.g. no rights on DBMS_LOCK)?
Then can happen following:

scott@XE> exec dbms_lock.sleep(10);
BEGIN dbms_lock.sleep(10); END;
 
      *
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00201: identifier 'DBMS_LOCK' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored


Any thoughts how to solve then his requirement in one line of code?

Cheers!
Paul M.

Posts: 8,657
Registered: 12/26/02
Re: waiting in a procedure (urgent)
Posted: Jul 9, 2006 3:13 AM   in response to: Faust - old acc... in response to: Faust - old acc...
Click to report abuse...   Click to reply to this thread Reply
Faust - old acc...

Posts: 524
Registered: 01/14/01
Re: waiting in a procedure (urgent)
Posted: Jul 9, 2006 3:22 AM   in response to: Paul M. in response to: Paul M.
Click to report abuse...   Click to reply to this thread Reply
William Robertson

Posts: 6,456
Registered: 06/17/98
Re: waiting in a procedure (urgent)
Posted: Jul 9, 2006 4:45 AM   in response to: Faust - old acc... in response to: Faust - old acc...
Click to report abuse...   Click to reply to this thread Reply
If the application being developed has a business requirement for a particular piece of Oracle functionality but has not been granted access to it, let me see, you can either

1. Get the permission granted, or
2. Write your own unsupported, less efficient, duplicate version of the Oracle functionality you have already paid for.

Surely Mr Mohannad Ghawi would not be requesting additional privileges for his own personal use, but as a developer he would be requesting them on behalf of the application he is working on, presumably backed up by a technical designer, team leader or manager who would confirm the business need as well the apparent urgency of the situation.
Faust - old acc...

Posts: 524
Registered: 01/14/01
Re: waiting in a procedure (urgent)
Posted: Jul 9, 2006 5:18 AM   in response to: William Robertson in response to: William Robertson
Click to report abuse...   Click to reply to this thread Reply
Surely Mr Mohannad Ghawi would not be requesting
additional privileges for his own personal use, but
as a developer he would be requesting them on behalf
of the application he is working on,
presumably
backed up by a technical designer, team leader or
manager who would confirm the business need as well
the apparent urgency of the situation.

Well developer will be in situation for "requesting additional privileges"
only if technical designer, team leader or manager forgot to concern such case during design of application!

In case of enterprise class application if often that
they must working properly in multi-user environment where
exists (of course) users with restricted privileges (e.g. no using DBMS_LOCK).

In that case helps following construct to avoid errors in
your application:

if user_with_restricted_privs then
  own unsupported code, duplicate version of the Oracle functionality you have already paid for.
else
  using Oracle functionality you have already paid for
end if;


Cheers!

Message was edited by:
Faust
Edit:
This "you have already paid for" apply not for users of XE :-)
William Robertson

Posts: 6,456
Registered: 06/17/98
Re: waiting in a procedure (urgent)
Posted: Jul 9, 2006 5:54 AM   in response to: Faust - old acc... in response to: Faust - old acc...
Click to report abuse...   Click to reply to this thread Reply
> In case of enterprise class application if often that
they must working properly in multi-user environment where
exists (of course) users with restricted privileges (e.g. no using DBMS_LOCK).

The execute privilege on DBMS_LOCK is not for an end user. There will be an application schema that owns the tables and packages and requires certain core privileges, and end users will have controlled access to this via role grants. The end users will never use DBMS_LOCK directly.

If for some reason only the SLEEP procedure within DBMS_LOCK is deemed safe for the applicaion to access, then a more privileged account could own a one-line wrapper procedure and grant execute on that to the application schema that needs to use it.
Paul M.

Posts: 8,657
Registered: 12/26/02
Re: waiting in a procedure (urgent)
Posted: Jul 9, 2006 6:21 AM   in response to: Faust - old acc... in response to: Faust - old acc...
Click to report abuse...   Click to reply to this thread Reply
SYS@db102 SQL> create or replace procedure sleep (seconds in number)
2 is
3 begin
4 dbms_lock.sleep (seconds);
5 end;
6 /

Procedure created.

SYS@db102 SQL> create or replace public synonym sleep for sleep;

Synonym created.

SYS@db102 SQL> grant execute on sleep to public;

Grant succeeded.

SYS@db102 SQL> create user test01 identified by test01;

User created.

SYS@db102 SQL> grant create session to test01;

Grant succeeded.

SYS@db102 SQL> conn test01/test01
Connected.
TEST01@db102 SQL> exec sleep(10);

PL/SQL procedure successfully completed.

TEST01@db102 SQL>
Legend
Guru Guru : 2500 - 1000000 pts
Expert Expert : 1000 - 2499 pts
Pro Pro : 500 - 999 pts
Journeyman Journeyman : 200 - 499 pts
Newbie Newbie : 0 - 199 pts
Oracle ACE Director
Oracle ACE Member
Oracle Employee ACE
Helpful Answer (5 pts)
Correct Answer (10 pts)

Point your RSS reader here for a feed of the latest messages in all forums