Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: How to ensure only one session runs PL/SQL proc at a time?

Re: How to ensure only one session runs PL/SQL proc at a time?

From: Ian Ledzion <ian.ledzion_at_lgxbow.com>
Date: Fri, 24 Aug 2001 08:33:46 +0200
Message-ID: <9m4si1$fop$1@rex.ip-plus.net>


Tested dbms_lock, and it works fine. Only problem I've had is that I can't use it from a trigger as the allocate_unique procedure issues a commit.

"Jonathan Lewis" <jonathan_at_jlcomp.demon.co.uk> wrote in message news:998557822.22905.0.nnrp-01.9e984b29_at_news.demon.co.uk...
>
> Have a look at the dbms_lock package.
> It exposes the normal enqueue mechanism
> to PL/SQL and allows you to take out 'UL'
> locks - but I think it has one extra special
> feature that you can define a lock to stay
> held across commits until explicitly released.
>
> --
> Jonathan Lewis
>
> Host to The Co-Operative Oracle Users' FAQ
> http://www.jlcomp.demon.co.uk/faq/ind_faq.html
>
> Author of:
> Practical Oracle 8i: Building Efficient Databases
> See http://www.jlcomp.demon.co.uk/book_rev.html
>
> For latest news of public appearances
> See http://www.jlcomp.demon.co.uk
>
> Screen saver or Life saver: http://www.ud.com
> Use spare CPU to assist in cancer research.
>
>
>
>
> Peter Marshall wrote in message <9m2ge2$u4i$1_at_news.x-echo.com>...
> >Does anyone know of an easy way to do this? I have a PL/SQL procedure co
> >mpiled in a package. I want to make sure that two sessions can't be runn
> >ing the procedure at the same time. It should work just like a database
> >resource lock -- the second comer waits until the first one is finished,
> > then it can run the procedure.
> >
> >I thought of using a lock on a database object (eg. the procedure tries
> >to take exclusive lock on a table, then release it at the end of the pro
> >cedure). But this wouldn't work, since I do DDL during the procedure, wh
> >ich would release the lock...
> >
> >I have looked around the manuals and thought about it, but nothing comes
> > to mind. Does anyone have a good solution for this?
> >
> >Thanks and regards,
> >Peter
> >
> >
> >=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> >Article poste via Voila News - http://www.news.voila.fr
> >Le : Thu Aug 23 10:55:30 2001 depuis l'IP : 195.15.152.196 [VIP 1597792]
>
>
Received on Fri Aug 24 2001 - 01:33:46 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US