Application Development 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: 

select single

Former Member
0 Kudos

hi guys can u tell me what should be the correct syntax for using a select single statement

i rthink we need to specify the primary key

in my table form which i am selecting there is only 2 fileds mandt and ztimestamp

i am selecting timestamp.

8 REPLIES 8

Former Member
0 Kudos

Hi,

Here is the syntax.

Select single ztimestamp from ZTABLE into <a_variable> where <condition>.

Regards,

Pramod

Former Member
0 Kudos

Hi,

Yes to get correct and accurate results you need to mention the primary key, As your table contains only 2 fields, you can omnit the where condition. It will fetch you the sing record in random.

Select single <fieldname>

into variable

from <tablename>.

Thanks & Regards,

Navneeth K.

former_member181995
Active Contributor
0 Kudos

>

> i rthink we need to specify the primary key

> i am selecting timestamp.

Answer is in your question itself.

you are doing right .

proceed.

Former Member
0 Kudos

Hi there in such a case directly write select single timestamp.

Actually it is not mandatory that to mention the complete key in the where clause, but it is always advisable to have that thing.. because select single means it will select only first record which satisfies the where clause,,

if it has complete key in the where clause then obviously it will fetch only one record thats why they will ask ti have complete key in the where clause...

Regards,

Sunil Kumar Mutyala

Former Member
0 Kudos

Hi

select single always return single record which is topmost even if your where clause satisfies many records.

Regards,

Vishal

Former Member
0 Kudos

Hi,

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.

Hope this helps.

Thanks,

Rahul Sinha

Former Member
0 Kudos

hi sushant

http://www.sapdb.org/7.4/htmhelp/40/1311fd2fa511d3a98100a0c9449261/content.htm

go through above link

i htink that will help u

Regards,

sindhu .G

Former Member
0 Kudos

thanks