Kbase 16165: Version 6 to Version 7 ESQL/C Record Locking Change
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  5/10/1998 |
|
Version 6 to Version 7 ESQL/C Record Locking Change
INTRODUCTION
============
This knowledgebase entry describes a change in ESQL/C record
locking from Version 6 to Version 7.
VERSION 6 BEHAVIOR
==================
In Version 6, when a cursor has been declared for update, the open
cursor statement will exclusive lock all the records retrieved for
the cursor.
VERSION 7 BEHAVIOR
==================
For Version 7, the behavior was changed so that Progress does not
get the records until they are actually needed (with a fetch). By
not getting the records until they are needed, those records are
not exclusive locked with the open cursor statement. As the
records in the cursor are fetched, they are exclusive locked until
transaction COMMIT or ROLLBACK.
MIGRATING AN APPLICATION FROM V6 TO V7
======================================
If you are migrating an ESQL/C application from Version 6 to
Version 7 and relied on the Version 6 behavior you should execute
a fetch and a "dummy update" to fetch the record from the cursor
so that the record has an exclusive lock.
The following pseudo code illustrates this technique. In this
code example, lock_tbl has only one record which matches the
selection criteria:
EXEC SQL DECLARE lock_cur CURSOR FOR
SELECT lock_rec
FROM lock_tbl
WHERE lock_key = :lockval
FOR UPDATE;
EXEC SQL OPEN lock_cur; /* In V6 this would lock the record */
EXEC SQL FETCH lock_cur /* In V7 this and the next update */
INTO :d_lock; /* statement are needed to lock the */
/* record */
EXEC SQL UPDATE lock_tbl
SET lock_rec = lock_rec
WHERE CURRENT OF lock_cur;
Progress Software Technical Support Note # 16165