Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

select single for update *...what does it do?

dev_parbutteea
Active Contributor
0 Likes
6,211

Hi .

In a standard program, a timeout is occuring because of this statement:

SELECT SINGLE FOR UPDATE * FROM NRIV WHERE

OBJECT = NRIV-OBJECT

AND SUBOBJECT = NRIV-SUBOBJECT

AND NRRANGENR = NRIV-NRRANGENR

AND TOYEAR = NRIV-TOYEAR.

When i checked the table NRIV, there were only 2000 entries in it.There is only 1 row which corresponds to the condition.This leads me to believe that the select single for update * is causing the timeout and not the volume of the db table.

What exactly does it mean and how can i correct it?

Hi .

In a standard program, a timeout is occuring because of this statement:

SELECT SINGLE FOR UPDATE * FROM NRIV WHERE

OBJECT = NRIV-OBJECT

AND SUBOBJECT = NRIV-SUBOBJECT

AND NRRANGENR = NRIV-NRRANGENR

AND TOYEAR = NRIV-TOYEAR.

When i checked the table NRIV, there were only 2000 entries in it.There is only 1 row which corresponds to the condition.This leads me to believe that the select single for update * is causing the timeout and not the volume of the db table.

What exactly does it mean and how can i correct it?

4 REPLIES 4
Read only

Former Member
0 Likes
3,220

Hi,

Check the Index settings of Table with ur BASIS team might be due to incorrect index which could cause TIMEOUT dump.

Regards,

Balakumar.G

Reward Points if helpful.

Read only

former_member194669
Active Contributor
0 Likes
3,220

Hi,

The DB lock created from a SELECT SINGLE FOR UPDATE will be released only after a COMMIT WORK.

Please check in SM12

Read only

Former Member
0 Likes
3,220

Hello,

The 'FOR UPDATE' addition on the SELECT will set write protection for NRIV. Anytime a table needs to be locked there is the possibility that two or more processes will be fighting for that table at the same time. This could cause the timeout in your case and eventually a deadlock.

Hope that helps a little.

Regards

Greg Kern

Read only

Former Member
0 Likes
3,220

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.

Regards,

Santosh