Page 1 of 1

Select for update => when unlocking is done?

Posted: Wed 09 Dec 2009 10:04
by albourgz
Hello,

I would like to prevent 2 users to perform the same action on different computers.
If a user updates a row, I would like the second user to be able to select row for update AFTER commit has happened on first computer (so that changes can be visible).

If I make a "select for update" in a TOraQuery (autocommit is off), I would like to know when this lock is released, is it released:
* when the cursor is closed?
* or when the current transaction is ended?
* or can I customize this somewhere?

Subsidiary question:
If I make a select for update in a toraquery, don't close the query, and a second toraquery in the same transaction (linked to same orasession) tries to perform an update on the rows selected in first query, will it be allowed?

Regards.

Posted: Wed 09 Dec 2009 10:28
by jfudickar
Hi,
i would suggest to use the dbms_lock package.

This is the best solution in my point of view.

Kind regards
Jens

Posted: Thu 10 Dec 2009 09:03
by Plash
The lock is released when you commit or rollback the transaction. Note that TOraQuery has the LockMode property. If this property has a value other than lmNone, ODAC automatically locks the record when you edit it.

If you lock records in one TOraQuery, you can change them in another TOraQuery that belong to the same session.