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

Regarding Select Query

Former Member
0 Likes
768

What is the difference between SELECT SINGLE* and SELECT...........UPTO ONE ROW?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
736

Hi

Both the statements are same in functionality point of view but differs only in Performance point of view.

Select single have good performance than select upto 1 row.

Thanks

Kiran.

6 REPLIES 6
Read only

Former Member
0 Likes
736

hi

select upto----this will select only records based on our requirement.

i.e if we give select kunnr nmae1 from kna1 upto one row.

this will give only one row from that table.

select single -


this will select single record from the table depending on where condition..

u can check in debugging ..the way data is fetched is different.

Edited by: Jyothsna M on Feb 19, 2008 8:12 AM

Read only

Former Member
0 Likes
736

Hi,

The only difference i believe is in syntax. Apart from that there is no difference. Both will get the first db reocord that matches the where condition. besides UPTO Can be used to fetch multiple rows.

Hope this helps..,

Thanks in advance,

Harikrishna Indugu.

Read only

Former Member
0 Likes
736

Hi

select single read db records with primary key.

select upto one row doesnt read for a primary key, instead it will try to find the most suitable index.

hence select upto one row is faster than select single if primary keys are not known.

Thanks

Vasudha

Read only

Former Member
0 Likes
736

HI,

The basic rule we follow in production is

Use SELECT SINGLE if you only need one result row or if you are validating whether the record exists and have the whole key.

If you read data using SELECT, it is worth using multiple operations (on an internal table) if you want to process the data more than once, otherwise, a simple SELECT loop is more efficient.

Avoid selecting all fields (i.e. SELECT *) unless absolutely necessary.

Watch the use of DISTINCT (it can perform badly and will bypass the buffer).

If you are doing a read to validate whether something is there (expecting only one record), use the UP TO 1 ROWS command after the INTO clause to avoid reading data you don’t need.

<REMOVED BY MODERATOR>

Edited by: Alvaro Tejada Galindo on Feb 19, 2008 2:11 PM

Read only

vinod_vemuru2
Active Contributor
0 Likes
736

Hi,

Use Select Single when u r sure that your where clause will get only one record. This will be generally used for selection screen validations.(Selects on check tables for checking valid entry or not)

Select upto one rows will also get one record but the difference is it will first select all the records which satisfies the where clause then it will return the first record.

Thanks,

Vinod.

Read only

Former Member
0 Likes
737

Hi

Both the statements are same in functionality point of view but differs only in Performance point of view.

Select single have good performance than select upto 1 row.

Thanks

Kiran.