‎2007 Mar 14 6:29 PM
Hi,
can anybody tell me the user of "SINGLE FOR UPDATE" keywords in SELECT statement?
Priya
‎2007 Mar 14 6:32 PM
Hi,
Please check this for SAP Help ...
If SINGLE is specified, the resulting set has a single line. If the remaining additions to the SELECT command select more than one line from the database, the first line that is found is entered into the resulting set. The data objects specified after INTO may not be internal tables, and the APPENDING addition may not be used.
An exclusive lock can be set for this line using the FOR UPDATE addition when a single line is being read with SINGLE. The SELECT command is used in this case only if all primary key fields in logical expressions linked by AND are checked to make sure they are the same in the WHERE condition. Otherwise, the resulting set is empty and sy-subrc is set to 8. If the lock causes a deadlock, an exception occurs. If the FOR UPDATE addition is used, the SELECT command circumvents SAP buffering.
Note
When SINGLE is being specified, the lines to be read should be clearly specified in the WHERE condition, for the sake of efficiency. When the data is read from a database table, the system does this by specifying comparison values for the primary key.
Regards,
Ferry Lianto
‎2007 Mar 14 6:33 PM
As given by SAP -
... SINGLE [FOR UPDATE]
If SINGLE is specified, the resulting set has a single line. If the remaining additions to the SELECT command select more than one line from the database, the first line that is found is entered into the resulting set. The data objects specified after INTO may not be internal tables, and the APPENDING addition may not be used. The addition ORDER BY can also not be used.
An exclusive <b>LOCK</b> can be set for this line using the FOR UPDATE addition when a single line is being read with SINGLE. The SELECT command is used in this case only if all primary key fields in logical expressions linked by AND are checked to make sure they are the same in the WHERE condition. Otherwise, the resulting set is empty and sy-subrc is set to 8. If the lock causes a deadlock, an exception occurs. If the FOR UPDATE addition is used, the SELECT command circumvents SAP buffering.
LOCK - Lock protected data from being accessed by several users at the same time as a shared lock or as exclusive locks
Regards,
Amit
Reward all helpful replies.
‎2007 Mar 14 6:35 PM
SINGLE FOR UPDATE addition to SELECT, select a single record into the specified workarea. Based on sy-subrc 0 which happens only if there is 1 record matching the criteria, you can use the actual UPDATE dbtable statement following it
‎2007 Mar 14 6:37 PM
Update is addition for SINGLE .
if you are using "select single for update" then the selected entry is protected against parallel updates from other transactions until the next database commit.
aRs
‎2007 Mar 14 6:43 PM
Hi,
SAP Explanation:
"An exclusive lock can be set for this line using the FOR UPDATE addition when a single line is being read with SINGLE. The SELECT command is used in this case only if all primary key fields in logical expressions linked by AND are checked to make sure they are the same in the WHERE condition. Otherwise, the resulting set is empty and sy-subrc is set to 8. If the lock causes a deadlock, an exception occurs. If the FOR UPDATE addition is used, the SELECT command circumvents SAP buffering."
When u are accessing a critical data which u dont want others to change while u r acessing, you make use of FOR UPDATE.
This is recommended to be mostly used with SINGLE, because u do not want to hold a bunch of records/values with out being changed by other users.
Hope this answers ur question.
Enjoy SAP
Rajasekhar