Locking question
Posted in 2006
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
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. -- Surfer! Email to: ramwater at uk2 dot net
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.