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

Former Member
0 Likes
795

hi all,

can anyone please tell me What is the difference between 'SELECT SINGLE' and 'SELECT UPTO ONE ROWS'?

regards saurabh.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
764

Hi,

SELECT SINGLE returns the first matching row for the given condition and it may not be unique, if there are more matching rows for the given condition.

SELECT ... UP TO 1 ROWS retrieves all the matching records and applies aggregation and ordering and returns the first record.

Inorder to check for the existence of a record then it is better to use SELECT SINGLE than using SELECT ... UP TO 1 ROWS since it uses low memory and has better performance."

Hope this helps u.

Thanks and Regards,

Ruthra

7 REPLIES 7
Read only

Former Member
0 Likes
764

The result is the same, but SELECT SINGLE should only be used if you can specify the primary key(s) fully.

Regards,

John.

Read only

Former Member
0 Likes
765

Hi,

SELECT SINGLE returns the first matching row for the given condition and it may not be unique, if there are more matching rows for the given condition.

SELECT ... UP TO 1 ROWS retrieves all the matching records and applies aggregation and ordering and returns the first record.

Inorder to check for the existence of a record then it is better to use SELECT SINGLE than using SELECT ... UP TO 1 ROWS since it uses low memory and has better performance."

Hope this helps u.

Thanks and Regards,

Ruthra

Read only

Former Member
0 Likes
764

Hi,

The 'SELECT SINGLE' statement selects the first row in the database that it finds that fulfils the 'WHERE' clause If this results in multiple records then only the first one will be returned and therefore may not be unique.

The 'SELECT .... UP TO 1 ROWS' statement is subtly different. The database selects all of the relevant records that are defined by the WHERE clause, applies any aggregate, ordering or grouping functions to them and then returns the first record of the result set.

<REMOVED BY MODERATOR>

Naresh.

Edited by: Alvaro Tejada Galindo on Jun 12, 2008 7:10 PM

Read only

Former Member
0 Likes
764

both statements return one row, but to improve performance of code

use 'select single'

Read only

Former Member
0 Likes
764

Hi,

Please learn to SEARCH - this is a basic question that has been asked and answered time and time again. Also try to use the F1 key on your keyboard or look at help.sap.com where all ABAP commands are explained. Also read the WIKI here on SDN.

Gareth.