<?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 statement using UP TO 1 rows in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-up-to-1-rows/m-p/4878480#M1140288</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check the index used for this SELECT.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 16 Dec 2008 14:25:25 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-12-16T14:25:25Z</dc:date>
    <item>
      <title>Select statement using UP TO 1 rows</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-up-to-1-rows/m-p/4878477#M1140285</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;&lt;/P&gt;&lt;P&gt;I know this is quite silly and basic but this is quite weird.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As far as my knowledge goes when UP TO 1 ROWS is used when the resultant set from the where condition has multiple records the below statement fetches the 1st record out of the set retreived to the buffer. This is working fine for all the cases except one where in the output is not the first record but the second one which is incidentally last record based on the where condition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  SELECT ebeln bednr loekz menge  FROM ekpo&lt;/P&gt;&lt;P&gt;  INTO (v_ebeln, v_bednr, v_loekz, l_orig_po_qty)&lt;/P&gt;&lt;P&gt;  UP TO 1 ROWS&lt;/P&gt;&lt;P&gt;  WHERE bednr = i_itab-bednr.&lt;/P&gt;&lt;P&gt;  ENDSELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Apart from changing the code is there any reason that we could justify why the first record is not being picked only in a specific instance??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;&amp;lt;Do not ask for or offer points&amp;gt;&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rgds,&lt;/P&gt;&lt;P&gt;Narendra.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Matt on Dec 16, 2008 3:25 PM - removed text&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Dec 2008 14:07:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-up-to-1-rows/m-p/4878477#M1140285</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-16T14:07:45Z</dc:date>
    </item>
    <item>
      <title>Re: Select statement using UP TO 1 rows</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-up-to-1-rows/m-p/4878478#M1140286</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The UP TO 1 Rows statement does not guarantee the first record from the database table - it will usually be the first but not always depending on the index used.  You might want to add a ORDER BY to your SELECT to make sure you get the record you want.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Dec 2008 14:20:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-up-to-1-rows/m-p/4878478#M1140286</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-16T14:20:16Z</dc:date>
    </item>
    <item>
      <title>Re: Select statement using UP TO 1 rows</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-up-to-1-rows/m-p/4878479#M1140287</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey Ken,&lt;/P&gt;&lt;P&gt;Thanks ... I am puzzled as this is behaving in this fashion only for a specific record and not for the rest.&lt;/P&gt;&lt;P&gt;So you say that UP TO 1 rows doesn't guarantee the 1st record rite??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Narendra.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Dec 2008 14:24:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-up-to-1-rows/m-p/4878479#M1140287</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-16T14:24:11Z</dc:date>
    </item>
    <item>
      <title>Re: Select statement using UP TO 1 rows</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-up-to-1-rows/m-p/4878480#M1140288</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check the index used for this SELECT.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Dec 2008 14:25:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-up-to-1-rows/m-p/4878480#M1140288</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-16T14:25:25Z</dc:date>
    </item>
    <item>
      <title>Re: Select statement using UP TO 1 rows</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-up-to-1-rows/m-p/4878481#M1140289</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;Hello Narendra,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think it is occurring because the record you think is the first in fact is not. Have you checked the date/time the records were created into EKPO table?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;/P&gt;&lt;P&gt;Daniel.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Dec 2008 14:25:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-up-to-1-rows/m-p/4878481#M1140289</guid>
      <dc:creator>daniel_carvalho</dc:creator>
      <dc:date>2008-12-16T14:25:32Z</dc:date>
    </item>
    <item>
      <title>Re: Select statement using UP TO 1 rows</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-up-to-1-rows/m-p/4878482#M1140290</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In a relational database there is no first and no last record. Only if you sort them you have a determined order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;up to 1 record does not mean gimme the first record, but means gimme just one record.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Dec 2008 14:27:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-up-to-1-rows/m-p/4878482#M1140290</guid>
      <dc:creator>rainer_hbenthal</dc:creator>
      <dc:date>2008-12-16T14:27:45Z</dc:date>
    </item>
    <item>
      <title>Re: Select statement using UP TO 1 rows</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-up-to-1-rows/m-p/4878483#M1140291</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok... So the essence is if we use UP TO 1 rows it doesnt guarantee the first record unless we use a sort by or order by additions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I believe a change of this statement is needed to fetch the desired results.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select single would be beneficial I guess in this case, which would obviously fetch the first record?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rgds,&lt;/P&gt;&lt;P&gt;Narendra&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Dec 2008 14:37:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-up-to-1-rows/m-p/4878483#M1140291</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-16T14:37:25Z</dc:date>
    </item>
    <item>
      <title>Re: Select statement using UP TO 1 rows</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-up-to-1-rows/m-p/4878484#M1140292</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Narendra,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT SINGLE does not fetch the First Record &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It fetches the Unique Record. SELECT SINGLE should be used only if you have the full primary key.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this is clear.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Suhas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Dec 2008 14:42:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-up-to-1-rows/m-p/4878484#M1140292</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2008-12-16T14:42:57Z</dc:date>
    </item>
    <item>
      <title>Re: Select statement using UP TO 1 rows</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-up-to-1-rows/m-p/4878485#M1140293</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No, &lt;STRONG&gt;select single&lt;/STRONG&gt; just returns a record that matches the where clause.  As Rainer already said - there's no concept of first/last record in a relational database.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Dec 2008 14:43:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-up-to-1-rows/m-p/4878485#M1140293</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2008-12-16T14:43:34Z</dc:date>
    </item>
    <item>
      <title>Re: Select statement using UP TO 1 rows</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-up-to-1-rows/m-p/4878486#M1140294</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;Thanks for your time.. I think these reasons would justify the change that is required at the code level.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One last query - as you say select single would fetch the record that matches the unique key, if I have 2 records that match the where condition then is there a rule that the result would be the first record only?? or as per the relational database concept there aint such thing??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rgds,&lt;/P&gt;&lt;P&gt;Narendra.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Dec 2008 14:49:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-up-to-1-rows/m-p/4878486#M1140294</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-16T14:49:18Z</dc:date>
    </item>
    <item>
      <title>Re: Select statement using UP TO 1 rows</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-up-to-1-rows/m-p/4878487#M1140295</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;as per relational database - there ain't no such thing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;matt&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Dec 2008 17:47:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-up-to-1-rows/m-p/4878487#M1140295</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2008-12-16T17:47:09Z</dc:date>
    </item>
    <item>
      <title>Re: Select statement using UP TO 1 rows</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-up-to-1-rows/m-p/4878488#M1140296</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI Narendra,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your select statement is fetching records from table based on date and time record was created into table.  Please check whether this criteria makes sense in your case.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If this is SAP table, most possibily it will log date and time record got created.  You can sort based on date and time created.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let me know if you have any questions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Krishna&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Dec 2008 18:10:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-up-to-1-rows/m-p/4878488#M1140296</guid>
      <dc:creator>nkr1shna</dc:creator>
      <dc:date>2008-12-16T18:10:03Z</dc:date>
    </item>
    <item>
      <title>Re: Select statement using UP TO 1 rows</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-up-to-1-rows/m-p/4878489#M1140297</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; Select single would be beneficial I guess in this case, which would obviously fetch the first record?&lt;/P&gt;&lt;P&gt;&amp;gt; Narendra&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What part of "in a relational database there is no first/last record" you didnt understand?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Dec 2008 18:14:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-up-to-1-rows/m-p/4878489#M1140297</guid>
      <dc:creator>rainer_hbenthal</dc:creator>
      <dc:date>2008-12-16T18:14:23Z</dc:date>
    </item>
    <item>
      <title>Re: Select statement using UP TO 1 rows</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-up-to-1-rows/m-p/4878490#M1140298</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Matt - Thank You.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rainer - Im not into databases so I do not understand these concepts..getting to know things out here.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rgds,&lt;/P&gt;&lt;P&gt;Narendra&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Dec 2008 05:56:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-up-to-1-rows/m-p/4878490#M1140298</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-17T05:56:43Z</dc:date>
    </item>
    <item>
      <title>Re: Select statement using UP TO 1 rows</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-up-to-1-rows/m-p/4878491#M1140299</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Had to modify the statement due to the inconsistent behaviour of the select up to 1 rows statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks everyone!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rgds,&lt;/P&gt;&lt;P&gt;Narendra.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Dec 2008 11:29:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-up-to-1-rows/m-p/4878491#M1140299</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-19T11:29:26Z</dc:date>
    </item>
  </channel>
</rss>

