Lock by read only SQL

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
jjeffman
Posts: 84
Joined: Tue 09 Nov 2004 12:22
Location: Porto Alegre-Rio Grande do Sul - Brazil

Lock by read only SQL

Post by jjeffman » Thu 14 Jul 2016 19:55

Hello.
Is there any way of having a record or a table locked by a select statement?

I have to concurrents applications, a UI one and a Windows service.

Mostly th Windows service writes data to the database, but it seems that the UI application was locking an update statement on the Windows service. I have changed the selected record on the UI application but the srevice was kept locked until the UI application connection was closed.

Is there any reason for that ? There was no any open transaction.

Thank you very much.

Kind regards.

Jayme Jeffman Filho.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Lock by read only SQL

Post by AlexP » Fri 15 Jul 2016 09:07

Hello,

If the SELECT FOR UPDATE construct is used in Pessimistic Mode, then a record is locked at the database level - and other applications can't modify this record. If you use a similar construct in your application, then on record update attempt you will get a corresponding error message that the record is locked. And you will be able to inform users about it.

Post Reply