Re: Locking question
Posted in 2006
In message <451ac477$0$14044$edfadb0f@dread15.news.tele.dk>, Claus
Samuelsen <csa@dk.ibm.com> writes
>Surfer! wrote:
>> Hi all
>> Using 4GL (7.20) I am looking for a way of doing the equivalent of a
>>shared table lock on a row.
>> The idea is to prevent a user coming along and taking an exclusive
>>lock on the row (and updating the information), but at the same time
>>allowing many users to view it.
>> Not sure how best to go about this - any suggestions that are
>>do-able with 4GL will be welcome.
>>
>
>First, ensure that your table has row locking.
> SELECT locklevel FROM systables WHERE tabname = 'your_table_name';> 'R' = row locking
> 'P' = page locking
> if lockmode = 'P' then
> ALTER TABLE your_table_name SET LOCK MODE (ROW);>
>Second, set the isolation level.
> If I remember correctly, you cannot change isolation level directly in 4GL,
> so you have to prepare the statement and then execute it.
> SET ISOLATION TO CURSOR STABILITY
> Default isolation level is COMMITTED READ>
>That's it.
Sorry I was after coding suggestions. We have lock mode row on all our
tables, and isolation mode is the same as SE, dirty read, as the code is
old. However the problem is in someone coming along and locking to
update a row for something that someone else is looking at, and it's OK
for lots of people to look at the same row at once - if it wasn't then
simply locking it for view or modify would work.
--
Surfer!
Email to: ramwater at uk2 dot net