Reputation: 129
When doing select on a table row in INFORMIX, how do you know if it is currently being locked by another user without using "for update" construct?
Upvotes: 1
Views: 678
Reputation: 370
Interesting question, and I am curious to know your motive and your end goal behind this question!
I do not believe there is a way (via select statement, without update) to find out if there a shared lock held on a row. Only when your session tries to modify the row you'll find out if some other session is holding a shared lock.
If you just want to know if there is an exclusive lock held on a row, then you can set your session isolation level to repeatable read.
set isolation to repeatable read;
select * from tab1 where col1=1;
The above information also assumes that the table itself uses row level locking (the default is page level locks).
NOTE: Repeatable Read is the most restrictive isolation level. (https://www.ibm.com/support/knowledgecenter/SSGU8G_12.1.0/com.ibm.sqls.doc/ids_sqs_0030.htm)
Upvotes: 2