LOCK is working on Basetable
============================

Kernel:          7.3.0  Build 029-000-087-809
RTE:    NT/INTEL 7.3.0  Build 029-000-087-809

Instance Type: OLTP 

Isolation Level: 0 (null)


According to the Documentation, LOCK statements don't work on basetables.

See "Reference Manual Version 7.2 and 7.3", Page 209,
LOCK statement explanation. There it says:

"The specified table cannot be a base table, a view table (see table 
[Page 29]), nor a synonym [Page30]. If the table name identifies a view
table, locks are set on the base tables on which ...."

The HTML-Manual states this as well.

However, this seems not to be true.
The following code fragment shows the code to lock a row in a base table.


  EXEC SQL 1 PREPARE dbLock FROM
    "LOCK ROW theusers KEY id = '0123456789' OPTIMISTIC";

  EXEC SQL 1 EXECUTE dbLock;


There is no error reported while executing and it's well working in the 
following scenario:


  // do the lock as above ..

  EXEC SQL 1 PREPARE dbSelectUserByID FROM
    "SELECT DIRECT id, nickname, psw, lastlogin INTO ?,?,?,? FROM theusers
KEY id = ?";

  // code ..

  EXEC SQL 1 EXECUTE dbSelectUserByID USING :hTheUserPM :ihTheUserPM,
:hSearchKey;

  // code .. 
  // but no following COMMIT !

  
According to the Prepcompiler Manual this is the recommended sequence for
OLTP.

Please note that in the preceding scenario the lock is NOT part of a 
select-statement-with-lock-option, i.e. SELECT ... FROM ... KEY ... WITH
LOCK...
It's a pure standalone lock some time before the select is done, so i
think i'am not mixing up things here.

A following UPDATE statement throws no error if the row is not changed by 
other users in the meantime, but if the locked row is changed or deleted 
by another user, an error is thrown as expected.

I think this is the way it have to work anyway.

I like how it works now (it just have to work like this) but the
differences of documentation and actual use is confusing.

Please tell me if i miss something and/or please clarify the manual.

thanks


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
_______________________________________________
sapdb.general mailing list
[EMAIL PROTECTED]
http://listserv.sap.com/mailman/listinfo/sapdb.general

Reply via email to