<?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 Dynamic SQL returns strange error if ORDER BY is missing in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-sql-returns-strange-error-if-order-by-is-missing/m-p/12308394#M1990664</link>
    <description>&lt;P&gt;Dear community,&lt;/P&gt;
  &lt;P&gt;I built this dynamic SQL to handle selection based on parameters passed to a REST services (e.g. $sort, $filter):&lt;/P&gt;
  &lt;P&gt;SELECT (iv_column_syntax) FROM (iv_source)&lt;BR /&gt; WHERE (iv_cond_syntax)&lt;BR /&gt;&lt;STRONG&gt;ORDER BY (lv_orderby)&lt;/STRONG&gt;&lt;BR /&gt; INTO CORRESPONDING FIELDS OF TABLE @et_entityset&lt;BR /&gt; UP TO @lv_top ROWS&lt;BR /&gt; OFFSET @lv_skip.&lt;/P&gt;
  &lt;P&gt;I noticed that deleting the ORDER BY clause in bold triggers a compile error:&lt;/P&gt;
  &lt;P&gt;&lt;EM&gt;Couldn't find Error Message: E SELECT 605 because the system is running&lt;BR /&gt;with the database objects from release 740. The system has not&lt;BR /&gt;completely upgraded to release 749.&lt;/EM&gt;&lt;/P&gt;
  &lt;P&gt;Same happens if lv_orderby is present, but empty. It does work when it is set to 'PRIMARY KEY', for instance.&lt;/P&gt;
  &lt;P&gt;On the other hand, old syntax SQL works. But I can't use OFFSET, as it available only in the new syntax.&lt;/P&gt;
  &lt;P&gt;SELECT (iv_column_syntax) FROM (iv_source)&lt;BR /&gt; UP TO lv_top ROWS&lt;BR /&gt; "OFFSET lv_skip&lt;BR /&gt; INTO CORRESPONDING FIELDS OF TABLE et_entityset&lt;BR /&gt; WHERE (iv_cond_syntax)&lt;BR /&gt; ORDER BY (lv_orderby).&lt;/P&gt;
  &lt;P&gt;Is this really due to an update currently running?&lt;/P&gt;</description>
    <pubDate>Wed, 27 Jan 2021 20:09:39 GMT</pubDate>
    <dc:creator>tudor_teoteoi</dc:creator>
    <dc:date>2021-01-27T20:09:39Z</dc:date>
    <item>
      <title>Dynamic SQL returns strange error if ORDER BY is missing</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-sql-returns-strange-error-if-order-by-is-missing/m-p/12308394#M1990664</link>
      <description>&lt;P&gt;Dear community,&lt;/P&gt;
  &lt;P&gt;I built this dynamic SQL to handle selection based on parameters passed to a REST services (e.g. $sort, $filter):&lt;/P&gt;
  &lt;P&gt;SELECT (iv_column_syntax) FROM (iv_source)&lt;BR /&gt; WHERE (iv_cond_syntax)&lt;BR /&gt;&lt;STRONG&gt;ORDER BY (lv_orderby)&lt;/STRONG&gt;&lt;BR /&gt; INTO CORRESPONDING FIELDS OF TABLE @et_entityset&lt;BR /&gt; UP TO @lv_top ROWS&lt;BR /&gt; OFFSET @lv_skip.&lt;/P&gt;
  &lt;P&gt;I noticed that deleting the ORDER BY clause in bold triggers a compile error:&lt;/P&gt;
  &lt;P&gt;&lt;EM&gt;Couldn't find Error Message: E SELECT 605 because the system is running&lt;BR /&gt;with the database objects from release 740. The system has not&lt;BR /&gt;completely upgraded to release 749.&lt;/EM&gt;&lt;/P&gt;
  &lt;P&gt;Same happens if lv_orderby is present, but empty. It does work when it is set to 'PRIMARY KEY', for instance.&lt;/P&gt;
  &lt;P&gt;On the other hand, old syntax SQL works. But I can't use OFFSET, as it available only in the new syntax.&lt;/P&gt;
  &lt;P&gt;SELECT (iv_column_syntax) FROM (iv_source)&lt;BR /&gt; UP TO lv_top ROWS&lt;BR /&gt; "OFFSET lv_skip&lt;BR /&gt; INTO CORRESPONDING FIELDS OF TABLE et_entityset&lt;BR /&gt; WHERE (iv_cond_syntax)&lt;BR /&gt; ORDER BY (lv_orderby).&lt;/P&gt;
  &lt;P&gt;Is this really due to an update currently running?&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jan 2021 20:09:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-sql-returns-strange-error-if-order-by-is-missing/m-p/12308394#M1990664</guid>
      <dc:creator>tudor_teoteoi</dc:creator>
      <dc:date>2021-01-27T20:09:39Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic SQL returns strange error if ORDER BY is missing</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-sql-returns-strange-error-if-order-by-is-missing/m-p/12308395#M1990665</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;Regarding the strange error message: Please check &lt;A href="https://apps.support.sap.com/sap/support/knowledge/en/2346369" target="_blank"&gt;KBA 2346369&lt;/A&gt;. It's not specifying 749 version specifially, but 7.42 and it might still be valid for you. Are you performing an upgrade currently, and is your code not yet unicode compliant, then that's probably it.&lt;/P&gt;&lt;P&gt;Regarding the SELECT statement and the ORDER BY thing. Yes, ORDER BY is required if you're using OFFSET, to ensure that the entries read are in the same expected order to get the expected result... &lt;A href="https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abapselect_up_to_offset.htm" target="_blank"&gt;Link to documentation&lt;/A&gt;. So it has to be there to run.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2021 05:48:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-sql-returns-strange-error-if-order-by-is-missing/m-p/12308395#M1990665</guid>
      <dc:creator>joltdx</dc:creator>
      <dc:date>2021-01-28T05:48:52Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic SQL returns strange error if ORDER BY is missing</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-sql-returns-strange-error-if-order-by-is-missing/m-p/12308396#M1990666</link>
      <description>&lt;P&gt;Hi Jörgen,&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Thanks for your answer. Indeed, I'm in this situation: ORDER BY is required if you're using OFFSET. The probably actually appeared when I tried SELECTing from JOINed tables, as the original ORDER BY PRIMARY KEY didn't work any more, so I replaced it with blank.&lt;/P&gt;&lt;P&gt;I can only blame the SAP compiler for a very misleading error message, as it took me hours to reach to the actual cause.&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;BR /&gt;Tudor&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2021 09:10:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-sql-returns-strange-error-if-order-by-is-missing/m-p/12308396#M1990666</guid>
      <dc:creator>tudor_teoteoi</dc:creator>
      <dc:date>2021-01-28T09:10:01Z</dc:date>
    </item>
  </channel>
</rss>

