<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Select Endselect or Select single in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-endselect-or-select-single/m-p/886449#M52576</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks to all for your responses.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I am seeking to resolve is that a blanket ban on SELECT...ENDSELECT is not correct.  Whilst in 99% of circumstances you should not use this construct, in this particular instance I believe it to be valid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have had incorrect data before when using a select single on an HR table and believe the creation of an internal table to get around the construct (while valid and used before by colleagues to avoid this issue) an unnecessary overhead.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I would like to do is update our QA process with correct information rather than follow a procedure to potentially create incorrect code and retrieve bad data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I agree with Mauricio's response entirely - obviously - and will use it as 'evidence'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Before I close the thread, does anyone else want to add anything?  Do you follow and formal standards documentation?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;Ian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 23 Feb 2005 18:36:45 GMT</pubDate>
    <dc:creator>IanStubbings</dc:creator>
    <dc:date>2005-02-23T18:36:45Z</dc:date>
    <item>
      <title>Select Endselect or Select single</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-endselect-or-select-single/m-p/886440#M52567</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Consider the following code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     SELECT * FROM hrp1000&lt;/P&gt;&lt;P&gt;      UP TO 1 ROWS&lt;/P&gt;&lt;P&gt;        WHERE plvar = ls_i1001-plvar&lt;/P&gt;&lt;P&gt;          AND otype = ls_i1001-otype&lt;/P&gt;&lt;P&gt;          AND objid = ls_i1001-sobid&lt;/P&gt;&lt;P&gt;          AND istat = '1'&lt;/P&gt;&lt;P&gt;          AND begda =&amp;lt; lv_begda&lt;/P&gt;&lt;P&gt;          AND endda =&amp;gt; lv_endda&lt;/P&gt;&lt;P&gt;          AND langu = sy-langu&lt;/P&gt;&lt;P&gt;      ORDER BY PRIMARY KEY.&lt;/P&gt;&lt;P&gt;      ENDSELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could this be replaced by a SELECT SINGLE?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We have a QA process which forbids SELECT...ENDSELECTs.  In this instance I believe a SELECT SINGLE to be erroneous. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any thoughts anyone?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance &lt;/P&gt;&lt;P&gt;Ian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Feb 2005 13:51:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-endselect-or-select-single/m-p/886440#M52567</guid>
      <dc:creator>IanStubbings</dc:creator>
      <dc:date>2005-02-23T13:51:35Z</dc:date>
    </item>
    <item>
      <title>Re: Select Endselect or Select single</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-endselect-or-select-single/m-p/886441#M52568</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Ian,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can as well use a SELECT SINGLE in this case, but there's a small glitch. You would get the result you desire, but there will be a warning in the EPC (Extended Program Check)which says that you have not specified the complete primary key. As you might have noticed, the table has just one more key field , SEQNR. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the EPC Warning is okay, I suppose you can go ahead with SELECT SINGLE, as long as you are just checking for the existence of some entries.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Anand Mandalika.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Feb 2005 13:59:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-endselect-or-select-single/m-p/886441#M52568</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-02-23T13:59:24Z</dc:date>
    </item>
    <item>
      <title>Re: Select Endselect or Select single</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-endselect-or-select-single/m-p/886442#M52569</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use SELECT INTO TABLE and avoid the SELECT...ENDSELECT issue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Feb 2005 14:02:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-endselect-or-select-single/m-p/886442#M52569</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-02-23T14:02:22Z</dc:date>
    </item>
    <item>
      <title>Re: Select Endselect or Select single</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-endselect-or-select-single/m-p/886443#M52570</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Ian,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As you properly said SELECT SINGLE in that case is erroneous. &lt;/P&gt;&lt;P&gt;The funny point is according to SAP Performance course, in that case the SELECT UP TO 1 ROWS is faster than SELECT SINGLE because you are not using all the primary key fields.&lt;/P&gt;&lt;P&gt;I belive your customer should restructure his QA process, because sometimes  SELECT...ENDSELECT statements are the right option to be used.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mauricio&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Feb 2005 14:14:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-endselect-or-select-single/m-p/886443#M52570</guid>
      <dc:creator>MauricioMiao</dc:creator>
      <dc:date>2005-02-23T14:14:37Z</dc:date>
    </item>
    <item>
      <title>Re: Select Endselect or Select single</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-endselect-or-select-single/m-p/886444#M52571</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the input guys.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My dilemma is that since it is an HR table and a date range is part of the key, if I am only using greater than less than expressions for these, a SELECT SINGLE could bring back the wrong information as it picks the first record it comes to.  It could be possible that a person has changed their name for instance and therefore has a more current record which the SELECT SINGLE cannot determine explicitly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is my assumption correct?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Feb 2005 14:15:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-endselect-or-select-single/m-p/886444#M52571</guid>
      <dc:creator>IanStubbings</dc:creator>
      <dc:date>2005-02-23T14:15:49Z</dc:date>
    </item>
    <item>
      <title>Re: Select Endselect or Select single</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-endselect-or-select-single/m-p/886445#M52572</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Possible workaround for this issue is to create a daterange and use this in your select statement. Overall only a select single can be sufficient if you have all key fields in you selection. In the case where date fields are part of the table key I believe a select single statement will not always ensure a correct command. Tiest.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Feb 2005 14:29:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-endselect-or-select-single/m-p/886445#M52572</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-02-23T14:29:37Z</dc:date>
    </item>
    <item>
      <title>Re: Select Endselect or Select single</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-endselect-or-select-single/m-p/886446#M52573</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Ian,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are you sure that there will be more than 1 record which will satisfy the date range condition? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In that case, how do you think SELECT UP TO 1 ROWS...ENDSELECT would be a better choice?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Anand Mandalika.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Feb 2005 14:33:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-endselect-or-select-single/m-p/886446#M52573</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-02-23T14:33:09Z</dc:date>
    </item>
    <item>
      <title>Re: Select Endselect or Select single</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-endselect-or-select-single/m-p/886447#M52574</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ian,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The result of both select single and select-end-select will be the same.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As others said, it might be a question of performance as select single is a construct designed to read database records with primary key. In the absence of the primary key, it might end up doing a sequential search, whereas the select up to 1 rows may assume that there is no primary key supplied and will try to find most suitable index.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The best way to find out is through sql trace or runtime analysis.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since your coding standards prohibit the use of select-endselect and with a reason, you might try the solution suggested in a reply here to use 'select into table' option and then read the internal table for the first record available.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But, please remember that you will do a "select up to 1 rows" only if you are sure that all the records returned will have the same value for the field(s) you are interested in. If not, you will be reading only the first record which matches the criteria, but may be the second or the third record has the value you are looking for.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Srinivas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Feb 2005 15:23:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-endselect-or-select-single/m-p/886447#M52574</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-02-23T15:23:13Z</dc:date>
    </item>
    <item>
      <title>Re: Select Endselect or Select single</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-endselect-or-select-single/m-p/886448#M52575</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have read a lot of threads concerning the issue - select single vs select * endselect and a lot of them stated that there would be a difference considering performance. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Personally I think this is a rumor but I confess that the investigation I made in this subject is limited to an oracle database and other databases may act differently.&lt;/P&gt;&lt;P&gt;What I did was rather simple. &lt;/P&gt;&lt;P&gt;I compared &lt;/P&gt;&lt;P&gt;select * from marc up to 1 rows where werks = l_werk. &lt;/P&gt;&lt;P&gt;endselect.&lt;/P&gt;&lt;P&gt;with &lt;/P&gt;&lt;P&gt;select single * from marc where werks = l_werk. &lt;/P&gt;&lt;P&gt;via st05 - sql trace. &lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;&lt;/P&gt;&lt;P&gt;Both statements were changed into the same native sql statement. So how would they react differently? &lt;/P&gt;&lt;P&gt; &amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;In my option - if you compare both selects you have to be fair. You may not use any select statements which makes a "sorting" of the result on databaselevel necessary such as aggregations or the "order by" statement. &lt;/P&gt;&lt;P&gt;If you do so you will get a different behaviour but then you simply do not the same anymore. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also you should not test it on buffered table (here it makes a difference how the table is buffered. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just my 2cts. &lt;/P&gt;&lt;P&gt;Christian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Feb 2005 17:32:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-endselect-or-select-single/m-p/886448#M52575</guid>
      <dc:creator>ChristianFi</dc:creator>
      <dc:date>2005-02-23T17:32:46Z</dc:date>
    </item>
    <item>
      <title>Re: Select Endselect or Select single</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-endselect-or-select-single/m-p/886449#M52576</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks to all for your responses.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I am seeking to resolve is that a blanket ban on SELECT...ENDSELECT is not correct.  Whilst in 99% of circumstances you should not use this construct, in this particular instance I believe it to be valid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have had incorrect data before when using a select single on an HR table and believe the creation of an internal table to get around the construct (while valid and used before by colleagues to avoid this issue) an unnecessary overhead.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I would like to do is update our QA process with correct information rather than follow a procedure to potentially create incorrect code and retrieve bad data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I agree with Mauricio's response entirely - obviously - and will use it as 'evidence'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Before I close the thread, does anyone else want to add anything?  Do you follow and formal standards documentation?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;Ian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Feb 2005 18:36:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-endselect-or-select-single/m-p/886449#M52576</guid>
      <dc:creator>IanStubbings</dc:creator>
      <dc:date>2005-02-23T18:36:45Z</dc:date>
    </item>
    <item>
      <title>Re: Select Endselect or Select single</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-endselect-or-select-single/m-p/886450#M52577</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I agree with Christian's analysis: as long as your statements are similar, most databases will translate into same native statement -&amp;gt; no DB performance difference can occur.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One minor point in ABAP part:&lt;/P&gt;&lt;P&gt;In debugging select ... up to 1 rows ... endselect you can follow execution:&lt;/P&gt;&lt;P&gt;- select statement&lt;/P&gt;&lt;P&gt;- endselect statement&lt;/P&gt;&lt;P&gt;- select statement&lt;/P&gt;&lt;P&gt;- first statement behind&lt;/P&gt;&lt;P&gt;So here mini loop is execute (but I'm discussing about nanoseconds, I know).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select single is executed as single command. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't like changes of programs to avoid trouble with automatic program checks or QA rules. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I would prepare myself with arguements and go into a fight (OK, never done it myself before).&lt;/P&gt;&lt;P&gt;Just because general rules don't fit to each situation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Additional programing (like ... into table + read) might be an easy way, but more lines of code violate one of the most important rules:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Keep it small and simple!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Christian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Feb 2005 18:51:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-endselect-or-select-single/m-p/886450#M52577</guid>
      <dc:creator>christian_wohlfahrt</dc:creator>
      <dc:date>2005-02-23T18:51:06Z</dc:date>
    </item>
    <item>
      <title>Re: Select Endselect or Select single</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-endselect-or-select-single/m-p/886451#M52578</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you please mention the reservation your QA have with using SELECT...ENDSELECT?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please keep one thing in mind that no matter what type of statement you issue, SELECT INTO TABLE, SELECT ENDSELECT, SELECT SINGLE, etc, they all translate to a single DB select statement and sent to the DB only once (unless you have issued a SELECT inside a LOOP). The DB selects data and sends it back in fixed packets to the app server. It is the processing of the resultset on app server that varies depending upon the construct used.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Feb 2005 05:38:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-endselect-or-select-single/m-p/886451#M52578</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-02-24T05:38:06Z</dc:date>
    </item>
    <item>
      <title>Re: Select Endselect or Select single</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-endselect-or-select-single/m-p/886452#M52579</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;   I did a Performance testing in the Split screen option in se30 with the modified form of Christian's code. I included matnr so as to satisy the primary key.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;tables marc.&lt;/P&gt;&lt;P&gt;select single * from marc &lt;/P&gt;&lt;P&gt;                 where matnr = 'MAT'&lt;/P&gt;&lt;P&gt;                 and   werks = 'ZZ02'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from marc up to 1 rows &lt;/P&gt;&lt;P&gt;                 where matnr = 'MAT'&lt;/P&gt;&lt;P&gt;                 and   werks = 'ZZ02'.&lt;/P&gt;&lt;P&gt;endselect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The System test result showed that the variant Single * takes less time than Up to 1 rows. The database that I did the testing is on Oracle. On debugging I found that when 'endselect' is there the System goes to the database twice even when it is 1 row. So doesn't these statistics indicate that select single is faster.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;Madhavan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Feb 2005 08:58:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-endselect-or-select-single/m-p/886452#M52579</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-02-25T08:58:11Z</dc:date>
    </item>
    <item>
      <title>Re: Select Endselect or Select single</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-endselect-or-select-single/m-p/886453#M52580</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello I checked my coding again with st05 &lt;/P&gt;&lt;P&gt;( I removed the where condition, though) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;report zztest .

tables marc.

select single * from marc.

select * from marc up to 1 rows.
endselect.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The result (and please note that the coding contains both selects was 1 open and 1 fetch for each select. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
 MARC       REOPEN      0      0 SELECT WHERE "MANDT" = '400' AND ROWNUM &amp;lt;= 1    
 MARC       FETCH       1      0                                                 
 MARC       REOPEN      0      0 SELECT WHERE "MANDT" = '400' AND ROWNUM &amp;lt;= 1    
 MARC       FETCH       1      0                                                 

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NB in my example the select single was slowlier (probably because the database cache was not filled at the time the first statement was executed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It could be however that the close cursor takes some extra time since it seems that this is done at the end of a select - endselect statement &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
       Brutto        Netto Zeile Include                          Aufruf                                                                                
62.451      5 /SEW/COPC_TEST01                 Select Single MARC  
                      870      7 /SEW/COPC_TEST01                 Fetch MARC          
                      468      7 /SEW/COPC_TEST01                 Open Cursor MARC    
                       20      7 /SEW/COPC_TEST01                 Fetch MARC          
                       12      8 /SEW/COPC_TEST01                 Close Cursor MARC                                                                                
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Feb 2005 10:02:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-endselect-or-select-single/m-p/886453#M52580</guid>
      <dc:creator>ChristianFi</dc:creator>
      <dc:date>2005-02-25T10:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: Select Endselect or Select single</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-endselect-or-select-single/m-p/886454#M52581</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Interesting news!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I copied Madhavan's example and made some tests. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First with complete key, then both statements where translated slightly different (Oracle database version 9.2.0.5.0) and select single was little bit faster.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But then I tested without matnr in where-clause. Then both  statements where translated identical, runtimes where identical.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We were discussing selection without complete key - and then both statements are handled identical.&lt;/P&gt;&lt;P&gt;In case complete (primary) key is available, select single is out of question best solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm almost feeling like a student making researches...&lt;/P&gt;&lt;P&gt;Christian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Feb 2005 10:31:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-endselect-or-select-single/m-p/886454#M52581</guid>
      <dc:creator>christian_wohlfahrt</dc:creator>
      <dc:date>2005-02-25T10:31:05Z</dc:date>
    </item>
    <item>
      <title>Re: Select Endselect or Select single</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-endselect-or-select-single/m-p/886455#M52582</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;here database differences appear:&lt;/P&gt;&lt;P&gt;my select single&lt;/P&gt;&lt;P&gt;   5 MARC       REOPEN             0 SELECT WHERE "MANDT" = '001' AND "MATNR" = 'XX' AND "WERKS" = '1000'&lt;/P&gt;&lt;P&gt; 289 MARC       FETCH       1      0                                                                                &lt;/P&gt;&lt;P&gt;my select up to 1 rows&lt;/P&gt;&lt;P&gt;   5 MARC       REOPEN             0 SELECT WHERE "MANDT" = '001' AND "MATNR" = 'XX' AND "WERKS" = '1000' AND ROWNUM &amp;lt;= 1&lt;/P&gt;&lt;P&gt; 299 MARC       FETCH       1      0                                                                                &lt;/P&gt;&lt;P&gt;I don't have close cursor. This would invoke additional network access (like I mentioned already with this 'mini-loop' example) - but depends obviously on database version.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Christian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Feb 2005 10:36:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-endselect-or-select-single/m-p/886455#M52582</guid>
      <dc:creator>christian_wohlfahrt</dc:creator>
      <dc:date>2005-02-25T10:36:33Z</dc:date>
    </item>
    <item>
      <title>Re: Select Endselect or Select single</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-endselect-or-select-single/m-p/886456#M52583</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think each one of us will be able to come up with certain results that will makes sense depending upon their own environment, work load, buffer condition, etc. I just tried out tracing both statements, specifying complete primary key. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For SELECT SINGLE, time taken to  fetch was 12.938&lt;/P&gt;&lt;P&gt;For SELECT ENDSELECT WITH UP TO 1 ROWS, time was 6.592&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since both statements were translated for the first time, hence preparing them and opening the cursor took some time as well but we are not discussing that. What might be more important is that the execution plan is more or less the same, only an additional level for COUNT STOP KEY for SELECT ENDSELECT UP TO 1 ROWS. But the estimated cost and rows are the same.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone please refer to the SAP Note that says SELECT SINGLE is better, or the other way around...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Feb 2005 10:46:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-endselect-or-select-single/m-p/886456#M52583</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-02-25T10:46:57Z</dc:date>
    </item>
    <item>
      <title>Re: Select Endselect or Select single</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-endselect-or-select-single/m-p/886457#M52584</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks to all for taking the time to reply to my query and apologies for the late reply - very busy week.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I fear we did stray a little from the original thrust though.  Performance is always important but the only reason for using the SELECT ENDSELECT this time was to produce the correct data where a SELECT SINGLE could not.  This is due to the date range used in the key of the table and therefore a SELECT SINGLE will not necessarily return the record that I want.  Using the ORDER BY PRIMARY KEY clause, I guarantee that the record being retrieved is correct. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM hrp1000&lt;/P&gt;&lt;P&gt;UP TO 1 ROWS&lt;/P&gt;&lt;P&gt;WHERE plvar = ls_i1001-plvar&lt;/P&gt;&lt;P&gt;AND otype = ls_i1001-otype&lt;/P&gt;&lt;P&gt;AND objid = ls_i1001-sobid&lt;/P&gt;&lt;P&gt;AND istat = '1'&lt;/P&gt;&lt;P&gt;AND begda =&amp;lt; lv_begda&lt;/P&gt;&lt;P&gt;AND endda =&amp;gt; lv_endda&lt;/P&gt;&lt;P&gt;AND langu = sy-langu&lt;/P&gt;&lt;P&gt;ORDER BY PRIMARY KEY.&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The constrct was rejected (initially) by QA for no other reason than the fact that ENDSELECTs are banned, even though in this case I also have the addition of UP TO ONE ROWS to ensure performance is not an issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Very interesting to see the the performance results which I can also use as evidence.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you all&lt;/P&gt;&lt;P&gt;Ian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 26 Feb 2005 07:20:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-endselect-or-select-single/m-p/886457#M52584</guid>
      <dc:creator>IanStubbings</dc:creator>
      <dc:date>2005-02-26T07:20:15Z</dc:date>
    </item>
    <item>
      <title>Re: Select Endselect or Select single</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-endselect-or-select-single/m-p/886458#M52585</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ian!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So you have still some doubts.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As Anand and Srinivas already stated, both selects will bring correct result - just what I think (ups, thought - see below).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But there is this 'order by primary key'-question. I think, on transparent tables without 'for all entries' no difference should occur - but who knows? At least most databases translate select single without complete key into &amp;lt;i&amp;gt;same&amp;lt;/i&amp;gt; native SQL as up to 1 row syntax.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You had already problems by switching to select single for a HR-table? Tell us in detail!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Okay, I had a detailed look at this table. Coming from pricing conditions, I can say: using valid from as key field is a problem (and both validity dates is worth).&lt;/P&gt;&lt;P&gt;It's strongly depending on maintenance transaction, which different validity ranges can occur to identical rest of key (except seqnr). If you can have two valid entries (meaning valid from &amp;lt;= today &amp;lt;= valid to) with different valid from values (because second 'current' entry was created later), then you are in trouble. But 'order by primary key' won't help, either. Then you have to sort by begda &amp;lt;b&amp;gt;descending&amp;lt;/b&amp;gt; (and not any longer by primary key). This leads to a statement, which can't any longer into identical select single -&amp;gt; you can 'survive' QA with endselect-statement (or you can prove rules as stupid).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't have seqnr &amp;gt; 0 (-&amp;gt; no example); I don't know maintenance transaction - but here crucial design questions are defined. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is still open question, I understand.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At least we got some very interesting performance analysis in between &lt;SPAN __jive_emoticon_name="wink"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Christian&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;P.S.: Sorry for long sentences, please read carefully &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 27 Feb 2005 10:55:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-endselect-or-select-single/m-p/886458#M52585</guid>
      <dc:creator>christian_wohlfahrt</dc:creator>
      <dc:date>2005-02-27T10:55:55Z</dc:date>
    </item>
    <item>
      <title>Re: Select Endselect or Select single</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-endselect-or-select-single/m-p/886459#M52586</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think there is a misunderstanding&lt;/P&gt;&lt;P&gt;select * from table up to 1 rows. endselect. and select single * from table gives the same result back provided the access method determined by the cost based optimizer is the same. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, to make sure that it is always in order of the primary key you have to add primary key which you cannot do with select single. So in this case you cannot rely on the result. Since he needs the order by primary key - his only choice is between&lt;/P&gt;&lt;P&gt; select up to 1 rows into table order by primary key &lt;/P&gt;&lt;P&gt;and &lt;/P&gt;&lt;P&gt; select up to 1 rows order by primary key. &lt;/P&gt;&lt;P&gt;Select single is not an option. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would not talk of incorrect results but it could be different ones. &lt;/P&gt;&lt;P&gt;Christian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 27 Feb 2005 11:26:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-endselect-or-select-single/m-p/886459#M52586</guid>
      <dc:creator>ChristianFi</dc:creator>
      <dc:date>2005-02-27T11:26:50Z</dc:date>
    </item>
  </channel>
</rss>

