<?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 single query working unexpectedly in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-single-query-working-unexpectedly/m-p/7994073#M1605930</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is as per the data in the table . The records are one below the another in database table.&lt;/P&gt;&lt;P&gt;So i feel it should have picked the first record.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 06 Jul 2011 06:16:31 GMT</pubDate>
    <dc:creator>former_member242512</dc:creator>
    <dc:date>2011-07-06T06:16:31Z</dc:date>
    <item>
      <title>Select single query working unexpectedly</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-single-query-working-unexpectedly/m-p/7994071#M1605928</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 have used below select single * query as shown :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have data in my table S022 as shown below, it has 2 records for material and aufnr combination :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; WERKS  ARBPL    kapar    MATNR                AUFNR       &lt;/P&gt;&lt;P&gt;                                                        &lt;/P&gt;&lt;P&gt; w1        ar1        004          mat1             000300156789&lt;/P&gt;&lt;P&gt; w1        ar2                        mat1             000300156789&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code used : &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;select single *                
   from s022                    
  where werks = itab-ltap-werks  "w1
    and matnr = w_matnr         "mat1
    and aufnr = w_aufnr. " 000300156789
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;        &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;runtime select query is picking second record i.e of ar2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope it should have picked ar1 record but its doesnt . &lt;/P&gt;&lt;P&gt;Also sometimes it picks 1st record for different data and for this data it picks the second record.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kindly help me to explain why its not picking the first record.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Jul 2011 04:46:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-single-query-working-unexpectedly/m-p/7994071#M1605928</guid>
      <dc:creator>former_member242512</dc:creator>
      <dc:date>2011-07-06T04:46:04Z</dc:date>
    </item>
    <item>
      <title>Re: Select single query working unexpectedly</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-single-query-working-unexpectedly/m-p/7994072#M1605929</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In the 2 records that you have mentioned, WERKS MATNR and AUFNR are having the same values.&lt;/P&gt;&lt;P&gt;So how do you assume it to take first record everytime.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Moreover ARBPL is a primary key,so either you have to pass it in your select statement&lt;/P&gt;&lt;P&gt;or SORT the internal table data based on ARBPL if you expect AR1 to be selcted first.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Jul 2011 04:56:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-single-query-working-unexpectedly/m-p/7994072#M1605929</guid>
      <dc:creator>GauthamV</dc:creator>
      <dc:date>2011-07-06T04:56:33Z</dc:date>
    </item>
    <item>
      <title>Re: Select single query working unexpectedly</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-single-query-working-unexpectedly/m-p/7994073#M1605930</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is as per the data in the table . The records are one below the another in database table.&lt;/P&gt;&lt;P&gt;So i feel it should have picked the first record.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Jul 2011 06:16:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-single-query-working-unexpectedly/m-p/7994073#M1605930</guid>
      <dc:creator>former_member242512</dc:creator>
      <dc:date>2011-07-06T06:16:31Z</dc:date>
    </item>
    <item>
      <title>Re: Select single query working unexpectedly</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-single-query-working-unexpectedly/m-p/7994074#M1605931</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Select single, ideally picks up the first matching entry from the table as per the where clause.&lt;/P&gt;&lt;P&gt;I know, that its not working for you, but could you tell what is your exact requirment.I mean which particular record do you wish to get.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Jul 2011 06:29:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-single-query-working-unexpectedly/m-p/7994074#M1605931</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-06T06:29:21Z</dc:date>
    </item>
    <item>
      <title>Re: Select single query working unexpectedly</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-single-query-working-unexpectedly/m-p/7994075#M1605932</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is as per the data in the table . The records are one below the another in database table.&lt;/P&gt;&lt;P&gt;&amp;gt; So i feel it should have picked the first record.&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hello Ujjwal,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The records shown in the databrowser is a snapshot of the entries in the DB &amp;amp; not how the recs are actually stored!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In RDBMS the sequence of entries is not defined at the DB layer. In SELECT SINGLE the 1st rec to be hit is returned to the result set. In your case this is the 2nd rec.&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>Wed, 06 Jul 2011 06:39:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-single-query-working-unexpectedly/m-p/7994075#M1605932</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2011-07-06T06:39:37Z</dc:date>
    </item>
    <item>
      <title>Re: Select single query working unexpectedly</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-single-query-working-unexpectedly/m-p/7994076#M1605933</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;write as select distinct select* to avoid the duplicates values&lt;/P&gt;&lt;P&gt;thanking you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Jul 2011 13:04:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-single-query-working-unexpectedly/m-p/7994076#M1605933</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-06T13:04:46Z</dc:date>
    </item>
    <item>
      <title>Re: Select single query working unexpectedly</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-single-query-working-unexpectedly/m-p/7994077#M1605934</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I just checked the table, and the table has lot of primary keys. you need to mention all the primary key in your read/select statement to pick the right record till then it will pick random records&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Jul 2011 13:14:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-single-query-working-unexpectedly/m-p/7994077#M1605934</guid>
      <dc:creator>Shahid</dc:creator>
      <dc:date>2011-07-06T13:14:44Z</dc:date>
    </item>
    <item>
      <title>Re: Select single query working unexpectedly</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-single-query-working-unexpectedly/m-p/7994078#M1605935</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Note:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;due to buffer and database architecture a select single without &lt;STRONG&gt;fully specified primary key&lt;/STRONG&gt; will return &lt;STRONG&gt;any&lt;/STRONG&gt; record that matches the where clause.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The records are not stored and not returned in a known order. Ask a database architect and she can tell you lots of stories.&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;Clemens&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Jul 2011 13:36:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-single-query-working-unexpectedly/m-p/7994078#M1605935</guid>
      <dc:creator>Clemenss</dc:creator>
      <dc:date>2011-07-06T13:36:54Z</dc:date>
    </item>
    <item>
      <title>Re: Select single query working unexpectedly</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-single-query-working-unexpectedly/m-p/7994079#M1605936</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Select Single is not appropriate if you cannot supply an equality condition for the entire primary key.  And, just out of curiosity, why from S022?  That will certainly guarantee very long runtime!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Jul 2011 13:57:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-single-query-working-unexpectedly/m-p/7994079#M1605936</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-06T13:57:31Z</dc:date>
    </item>
    <item>
      <title>Re: Select single query working unexpectedly</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-single-query-working-unexpectedly/m-p/7994080#M1605937</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;Thanks all for your valuable answers.&lt;/P&gt;&lt;P&gt;My assumption was wrong and thanks for giving the clearity.&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, 21 Jul 2011 09:59:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-single-query-working-unexpectedly/m-p/7994080#M1605937</guid>
      <dc:creator>former_member242512</dc:creator>
      <dc:date>2011-07-21T09:59:38Z</dc:date>
    </item>
  </channel>
</rss>

