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

Home -> Community -> Usenet -> c.d.o.server -> Re: How to add / remove a lock from a table?

Re: How to add / remove a lock from a table?

From: Giorgio Sorbara <NoSp_at_m>
Date: Fri, 23 Mar 2001 18:17:11 +0100
Message-ID: <3abb84d8$0$13429$73bec57d@news.be.uu.net>

Select row_you_need
  from your_table
 where field = value FOR UPDATE;

This locks only the row(s) selected.
Then to remove the lock you should either commit or rollback.

/Giorgio

PS: why you need to create the sequence manually? if is an identity you're looking for, is the sequence object so hard to deal with?

"Nick Tentomas" <Ntentoma_at_CSBFACMGT.CSBFM.DAL.CA> wrote in message news:3ABB72A0.28B2A499_at_CSBFACMGT.CSBFM.DAL.CA...
> Thanks Zoran,
>
> How about if you want to lock a row on a table? I am creating sequences
 manually
> and I need to make sure the user gets the next sequence value before a new
 one
> has been generated.
>
> Thanks in advance,
>
> Nick
>
>
>
> Zoran Marjanski wrote:
>
> > Use the LOCK TABLE sql statement. Look it up in the SQL Reference
 manual.
> > Use COMMIT or ROLLBACK to unlock the table lock.
> >
> > But this LOCKS the entire table. If that's what you want good. Most of
 the
> > time, the builtin row level locking is sufficient.
> >
> > The Oracle DB provides row level locking when updates are performed.
 There's
> > no need to explicitly lock rows, usually. An UPDATE sql statement
> > automatically locks rows that are being updated, until a COMMIT or
 ROLLBACK
> > is performed. While your SQL session has rows locked for update, other
 SQL
> > sessions, see the old values of the data, until you COMMIT. This is read
> > consistency. Most modern SQL databases provide this and is nothing new.
> >
> > Hope this helps.
> >
> > Zoran.
> >
> > "Nick Tentomas" <Ntentoma_at_CSBFACMGT.CSBFM.DAL.CA> wrote in message
> > news:3AB8C78D.E5C22DCA_at_CSBFACMGT.CSBFM.DAL.CA...
> > > Hello,
> > >
> > > I am very new to Oracle so I might be asking something very simple. I
> > > was wondering if anybody know how to set a lock for read/write on a
> > > table and when I finish how to remove the lock.
> > >
> > > Thanks in advance,
> > >
> > > Nick
> > >
>
Received on Fri Mar 23 2001 - 11:17:11 CST

Original text of this message

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