Page 1 of 1

Lock by read only SQL

Posted: Thu 14 Jul 2016 19:55
by jjeffman
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.

Re: Lock by read only SQL

Posted: Fri 15 Jul 2016 09:07
by AlexP
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.