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

query

Former Member
0 Likes
728

what is the difference between Select single* from tablename..and select upto one rows

5 REPLIES 5
Read only

Former Member
0 Likes
708

The result is same it selects the 1st row.

But performance wise is diift

If you specify full keys to select single it will give you a better performance

Hope it helps

Read only

Former Member
0 Likes
708

hi,

Select Single and the Select up to 1 rows is used to extract the single row from the database.

The exact diff is:

If we know In mara table has a primary key field has a matnr, that for each material number only one record exists,

duplicates not allowed.

If use Select Single Command to get that one record . It will not again go tot check for if there is another record available for same matnr.

we use select up to 1 rows it will extarct the 1 row from the

dbtable and again it will go and check if there is another record availble or not for same material no.

It will take one extra rotattion.

Keep in mind if use select single u make to populate all the key fields. Otherwise it will extract the first row from the database.

data: it_mara like mara occurs 1 with header line.

Select single * from mara into it_mara where matnr = '000000000100000174'.

append it_mara.

select * from mara into it_mara

up to 1 rows

where matnr = '000000000100000174'.

append it_mara.

endselect.

Loop at it_mara.

endloop.

U can execute above code put break point feel the diff.

regards,

pavan,

Read only

sivasatyaprasad_yerra
Product and Topic Expert
Product and Topic Expert
0 Likes
708

SELECT SINGLE * returns the first record which was satisfied from the data base

SELECT UPTO n ROWS returns the first 'n' records which satisfies the condition from the data base. 'n' should be integer value. If 'n' is 0, it is like select *

Regards,

Siva.

Read only

Former Member
0 Likes
708

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 or lack of, applies any aggregate, ordering or grouping functions to them and then returns the first record of the resultant result set.

Regards.