Select for update => when unlocking is done?

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
albourgz
Posts: 160
Joined: Wed 06 May 2009 12:17
Location: belgium

Select for update => when unlocking is done?

Post by albourgz » Wed 09 Dec 2009 10:04

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.

jfudickar
Posts: 202
Joined: Fri 10 Mar 2006 13:03
Location: Oberursel / Germany

Post by jfudickar » Wed 09 Dec 2009 10:28

Hi,
i would suggest to use the dbms_lock package.

This is the best solution in my point of view.

Kind regards
Jens

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Thu 10 Dec 2009 09:03

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.

Post Reply