row-level locking

Started by Markus Wagnerabout 23 years ago3 messagesgeneral
Jump to latest
#1Markus Wagner
wagner@imbei.uni-mainz.de

Hi,

we need to prevent write access for a single row of a table for a short time.

We found a short description for the "SELECT FOR UPDATE" statement:
"perform exclusive locking of selected rows"

Now my question: Is this a good method for our purpose?

Assuming that we lock our row with
"SELECT FOR UPDATE FROM <table> WHERE <our condition>",
how can we unlock it later?

Do we have to put the whole thing in a transaction (which may be tricky from
within a VB-Application...)?

Thanks a lot,
Markus

#2Markus Wagner
wagner@imbei.uni-mainz.de
In reply to: Markus Wagner (#1)
Re: row-level locking

Hi all,

thanks a lot for these *quick* answers!

Markus

On Tuesday 01 April 2003 13:36, Markus Wagner wrote:

Show quoted text

Now my question: Is this a good method for our purpose?

#3Muhammad Shariq Muzaffar
shariq77@yahoo.com
In reply to: Markus Wagner (#1)
Re: row-level locking

All you have to do is to call the BeginTrans method of
the Connecion object of ADO in VB using ODBC.

While in transaction mode you can lock as many rows as
you want using "Select .... For Update" query but
remember that if the row is already locked by some
other user/client, all the rows locked by your
transaction will be automatically rolledback. To
release the locked rows you can either call the
RollbackTrans or CommitTrans method of the Connection
object.

 --- Markus Wagner <wagner@imbei.uni-mainz.de> wrote:

Hi,

we need to prevent write access for a single row of
a table for a short time.

We found a short description for the "SELECT FOR
UPDATE" statement:
"perform exclusive locking of selected rows"

Now my question: Is this a good method for our
purpose?

Assuming that we lock our row with
"SELECT FOR UPDATE FROM <table> WHERE <our
condition>",
how can we unlock it later?

Do we have to put the whole thing in a transaction
(which may be tricky from
within a VB-Application...)?

Thanks a lot,
Markus

---------------------------(end of
broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

__________________________________________________
Yahoo! Plus
For a better Internet experience
http://www.yahoo.co.uk/btoffer