<?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 Database table Select in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/database-table-select/m-p/9582687#M1756624</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Gurus,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I am facing a strange issue where I have a select from a custom table &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="L0S52"&gt;SELECT *&lt;BR /&gt;&amp;nbsp; &lt;SPAN class="L0S52"&gt;FROM &lt;/SPAN&gt;ZXXX&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S52"&gt;&amp;nbsp; &lt;SPAN class="L0S52"&gt;INTO &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;TABLE &lt;/SPAN&gt;t_ZXXX&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S52"&gt;&lt;SPAN class="L0S55"&gt;IF sy-subrc = 0.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S52"&gt;&lt;SPAN class="L0S55"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S52"&gt;&lt;SPAN class="L0S55"&gt;ENDIF.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S52"&gt;&lt;SPAN class="L0S55"&gt;If I put a breakpoint at IF sy-subrc = 0 in Development environment and Quality Environment and debug, I can see that the entries are in different sequence in the two environment (I thought if there is no sorting on the internal table, default the entries will be sorted based on the primary keys of the database table). However, there is no sorting on the internal table. Is there any specific reason for this or some BASIS settings. Thanks for the help in advance.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 12 Jul 2013 14:03:46 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2013-07-12T14:03:46Z</dc:date>
    <item>
      <title>Database table Select</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/database-table-select/m-p/9582687#M1756624</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Gurus,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I am facing a strange issue where I have a select from a custom table &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="L0S52"&gt;SELECT *&lt;BR /&gt;&amp;nbsp; &lt;SPAN class="L0S52"&gt;FROM &lt;/SPAN&gt;ZXXX&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S52"&gt;&amp;nbsp; &lt;SPAN class="L0S52"&gt;INTO &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;TABLE &lt;/SPAN&gt;t_ZXXX&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S52"&gt;&lt;SPAN class="L0S55"&gt;IF sy-subrc = 0.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S52"&gt;&lt;SPAN class="L0S55"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S52"&gt;&lt;SPAN class="L0S55"&gt;ENDIF.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S52"&gt;&lt;SPAN class="L0S55"&gt;If I put a breakpoint at IF sy-subrc = 0 in Development environment and Quality Environment and debug, I can see that the entries are in different sequence in the two environment (I thought if there is no sorting on the internal table, default the entries will be sorted based on the primary keys of the database table). However, there is no sorting on the internal table. Is there any specific reason for this or some BASIS settings. Thanks for the help in advance.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jul 2013 14:03:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/database-table-select/m-p/9582687#M1756624</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-07-12T14:03:46Z</dc:date>
    </item>
    <item>
      <title>Re: Database table Select</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/database-table-select/m-p/9582688#M1756625</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The order in which SELECT statement fetches records from database can vary if you dont use "ORDER BY" addition.In order to sort data fetched using SELECT statement by primary key give addition:&lt;SPAN style="color: #000000; font-family: 'Courier New'; font-weight: bold; background-color: #f2f4f7;"&gt;ORDER BY PRIMARY KEY.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12px; background-color: #ffffff; color: #333333;"&gt;&lt;SPAN class="L0S52" style="font-style: inherit; font-family: inherit;"&gt;SELECT *&lt;BR /&gt;&amp;nbsp; &lt;SPAN class="L0S52" style="font-style: inherit; font-family: inherit;"&gt;FROM &lt;/SPAN&gt;ZXXX&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; background-color: #ffffff; color: #333333;"&gt;&lt;SPAN class="L0S52" style="font-style: inherit; font-family: inherit;"&gt;&amp;nbsp; &lt;SPAN class="L0S52" style="font-style: inherit; font-family: inherit;"&gt;INTO &lt;/SPAN&gt;&lt;SPAN class="L0S52" style="font-style: inherit; font-family: inherit;"&gt;TABLE &lt;/SPAN&gt;t_ZXXX&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; background-color: #ffffff; color: #333333;"&gt;&lt;SPAN class="L0S52" style="font-style: inherit; font-family: inherit;"&gt;&lt;STRONG&gt; ORDER BY PRIMARY KEY.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12px; background-color: #ffffff; color: #333333;"&gt;&lt;SPAN class="L0S52" style="font-style: inherit; font-family: inherit;"&gt;The "ORDER BY" addition can impact query performance, so consider sorting internal table data after data is read from database.&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12px; background-color: #ffffff; color: #333333;"&gt;&lt;SPAN class="L0S52" style="font-style: inherit; font-family: inherit;"&gt;Regards&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; background-color: #ffffff; color: #333333;"&gt;&lt;SPAN class="L0S52" style="font-style: inherit; font-family: inherit;"&gt;&lt;SPAN class="L0S55" style="font-style: inherit; font-family: inherit;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: 'Courier New'; font-weight: bold; background-color: #f2f4f7;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: 'Courier New'; font-weight: bold; background-color: #f2f4f7;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jul 2013 15:17:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/database-table-select/m-p/9582688#M1756625</guid>
      <dc:creator>former_member188827</dc:creator>
      <dc:date>2013-07-12T15:17:35Z</dc:date>
    </item>
    <item>
      <title>Re: Database table Select</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/database-table-select/m-p/9582689#M1756626</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Subhajit,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The underlying database is generally relational one and the sequence of records fetched via SELECT is random and does not follow any pattern.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want it to obey any patter use Clauses like ORDER BY &amp;lt;any field&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jul 2013 19:07:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/database-table-select/m-p/9582689#M1756626</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-07-12T19:07:02Z</dc:date>
    </item>
    <item>
      <title>Re: Database table Select</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/database-table-select/m-p/9582690#M1756627</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I &lt;EM&gt;believe&lt;/EM&gt; that the sequence is not random, but according to an internal ID specific to the database (for Oracle: ROWID), so essentially the entries would appear e.g. in the order as they were added to the database, which can be different in each system. So for a reliable program logic they will need to be sorted explicitely as described.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jul 2013 20:10:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/database-table-select/m-p/9582690#M1756627</guid>
      <dc:creator>ThomasZloch</dc:creator>
      <dc:date>2013-07-12T20:10:00Z</dc:date>
    </item>
    <item>
      <title>Re: Database table Select</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/database-table-select/m-p/9582691#M1756628</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;Whenever SAP selects data from any database table, it selects data after matching the&lt;EM&gt;&lt;STRONG&gt; where&lt;/STRONG&gt;&lt;/EM&gt; conditions with the index: &lt;STRONG&gt;primary and secondary&lt;/STRONG&gt;. If it finds one which matches the criteria, it automatically selects data based on that, and sorts the data as well. &lt;/P&gt;&lt;P&gt;Regarding your case, can you see if you have any key maintained for your table????&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Arpan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 14 Jul 2013 18:36:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/database-table-select/m-p/9582691#M1756628</guid>
      <dc:creator>Saha_Arpan</dc:creator>
      <dc:date>2013-07-14T18:36:25Z</dc:date>
    </item>
    <item>
      <title>Re: Database table Select</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/database-table-select/m-p/9582692#M1756629</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;Yes you can use the "ORDER BY" clause. But my advice is to add a SORT statement after the fetch to reduce the overhead on the database.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Jul 2013 04:16:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/database-table-select/m-p/9582692#M1756629</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-07-15T04:16:25Z</dc:date>
    </item>
    <item>
      <title>Re: Database table Select</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/database-table-select/m-p/9582693#M1756630</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for all your response. Actually it is an old program and used to work fine earlier. That is strange. I think I need to sort it by the primary key after the select is done and then check. Please confirm.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Jul 2013 08:01:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/database-table-select/m-p/9582693#M1756630</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-07-15T08:01:43Z</dc:date>
    </item>
    <item>
      <title>Re: Database table Select</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/database-table-select/m-p/9582694#M1756631</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are many reasons that can change the order data are read from database, so better use ORDER BY or SORT the data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I remember an old note following a system update (was on iSeries, &lt;A class="urLnkFunction urVt1" href="https://service.sap.com/sap/support/notes/743113" title="Right mouse click to add this SAP Note to your browser favorites"&gt;&lt;SPAN class="urTxtH1" id="header_data"&gt;Note 743113 - iSeries: Known Issues with V5R3M0&lt;/SPAN&gt;&lt;/A&gt;) there are many similar notes on the same problem with almost every database.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;5. Correct the report(s) by adding the 'ORDER BY' clause to the&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; SELECTs. If the clause is not specified then the records may be&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; returned in a random sequence. Even if the records are usually&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; returned in primary key sequence, you should not rely on this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; happening.&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Raymond&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Jul 2013 09:09:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/database-table-select/m-p/9582694#M1756631</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2013-07-15T09:09:32Z</dc:date>
    </item>
  </channel>
</rss>

