Skip to Content
author's profile photo Former Member
Former Member

Regarding Select Query

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Feb 19, 2008 at 02:51 PM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 19, 2008 at 07:11 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 19, 2008 at 07:17 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 19, 2008 at 07:11 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 19, 2008 at 07:12 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Feb 19, 2008 at 02:37 PM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.