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

Home -> Community -> Mailing Lists -> Oracle-L -> Re: How do you use DBMS_LOCK?

Re: How do you use DBMS_LOCK?

From: Jared Still <jkstill_at_cybcon.com>
Date: Sun, 15 Feb 2004 14:00:21 -0800
Message-Id: <1076882421.2838.7272.camel@poirot>


I've used it to restrict access to a sequence.

This particular sequence is reset to 0 at midnight every night.

The code to get the next sequence looks like this:

   dbms_lock.request
   dbms_lock.release
   get next sequence number

The code that runs a midnight takes out the lock, and hold onto it until maintenance is complete, then releases.

So for a few seconds any new requests for the next sequence value queue up behind maintenance.

There is a race condition should a request for a new sequence value occur at the same time as the maintenance code. This results in an ambiguity as to whether this transaction becomes the last one for a day or the first one for the next day.

It was important though, so I didn't try to deal with that.

Jared

this would
On Sat, 2004-02-14 at 06:49, Ryan wrote:
> Tom Kyte has a use for it in his book. You create your own Insert Lock. I used it once last year. All I did was create a wrapper to make it easier for others to use it. I was just a contractor there so I didnt get the big picture.
> What have you used DBMS_LOCK for? Anything interesting any useful? Anyone have any code samples? I've used locks in java and unix when I do threading, I have not seen much cause for it inside the Oracle database.
> ----------------------------------------------------------------
> Please see the official ORACLE-L FAQ: http://www.orafaq.com
> ----------------------------------------------------------------
> To unsubscribe send email to: oracle-l-request_at_freelists.org
> put 'unsubscribe' in the subject line.
> --
> Archives are at http://www.freelists.org/archives/oracle-l/
> FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html
> -----------------------------------------------------------------



Please see the official ORACLE-L FAQ: http://www.orafaq.com

To unsubscribe send email to: oracle-l-request_at_freelists.org put 'unsubscribe' in the subject line.
--
Archives are at http://www.freelists.org/archives/oracle-l/
FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html
-----------------------------------------------------------------
Received on Sun Feb 15 2004 - 16:00:21 CST

Original text of this message

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