<?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: Dump on single-row subquery in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dump-on-single-row-subquery/m-p/7504696#M1558854</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Daniel,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think, that table cabnt won't have many rows on your production server. Check it out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Furthemore you can make some combinations of this code f.e. remove DB sorting and use ABAP SORT BY statement.&lt;/P&gt;&lt;P&gt;It should be faster I think. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Moreover&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
SELECT var
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is faster than &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
SELECT *
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But like I said before this table is quite small ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards, Daniel.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 17 Nov 2010 12:45:47 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-11-17T12:45:47Z</dc:date>
    <item>
      <title>Dump on single-row subquery</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dump-on-single-row-subquery/m-p/7504690#M1558848</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm using the following select statement, which causes a dump "DBIF_RSQL_SQL_ERROR" (ORA-01427: single-row subquery returns more than one row) and I don't know why:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: atbez LIKE cabnt-atbez.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT SINGLE atbez FROM cabnt INTO atbez&lt;/P&gt;&lt;P&gt;WHERE atinn = '0000002134'&lt;/P&gt;&lt;P&gt;  AND spras = 'D'&lt;/P&gt;&lt;P&gt;  AND adzhl =&lt;/P&gt;&lt;P&gt;  ( SELECT MAX( adzhl ) FROM cabnt WHERE atinn = cabnt~atinn&lt;/P&gt;&lt;P&gt;                                     AND spras = 'D'&lt;/P&gt;&lt;P&gt;      GROUP BY atinn spras ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Why does the subquery return more than one row, if ATINN, SPRAS and ADZHL are the only key fields of table CABNT?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anybody help me?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Nov 2010 10:37:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dump-on-single-row-subquery/m-p/7504690#M1558848</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-11-17T10:37:09Z</dc:date>
    </item>
    <item>
      <title>Re: Dump on single-row subquery</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dump-on-single-row-subquery/m-p/7504691#M1558849</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Daniel,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I guess, writing the code in below fashion can solve the dump,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT SINGLE atbez FROM cabnt INTO atbez&lt;/P&gt;&lt;P&gt;WHERE atinn = cabnt~atinn&lt;/P&gt;&lt;P&gt;AND spras = 'D'&lt;/P&gt;&lt;P&gt;AND adzhl =&lt;/P&gt;&lt;P&gt;( SELECT MAX( adzhl ) FROM cabnt WHERE atinn =  '0000002134'&lt;/P&gt;&lt;P&gt;AND spras = 'D'&lt;/P&gt;&lt;P&gt;GROUP BY atinn spras ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let me know if that works!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Abhishek&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Nov 2010 11:12:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dump-on-single-row-subquery/m-p/7504691#M1558849</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-11-17T11:12:18Z</dc:date>
    </item>
    <item>
      <title>Re: Dump on single-row subquery</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dump-on-single-row-subquery/m-p/7504692#M1558850</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Daniel,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead of writing a sub query, write a separate query to get max of adzhl&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*--To get adzhal possible values for each atinn and spras&lt;/P&gt;&lt;P&gt;select adzhl&lt;/P&gt;&lt;P&gt;from cabnt&lt;/P&gt;&lt;P&gt;into t_cabnt&lt;/P&gt;&lt;P&gt;where atinn = p_atinn and&lt;/P&gt;&lt;P&gt;           spras = p_spras.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sort t_cabnt by  atinn ascending spras ascending adzhl descending.&lt;/P&gt;&lt;P&gt;delete adjacent duplicates from t_cabnt by comparing adzhl.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Above code will return you the max value for adzhl for each atinn and spras. Now you can write the main query &lt;/P&gt;&lt;P&gt;SELECT SINGLE atbez FROM cabnt INTO atbez&lt;/P&gt;&lt;P&gt;for all entries in t_cabnt&lt;/P&gt;&lt;P&gt;WHERE atinn = '0000002134'&lt;/P&gt;&lt;P&gt;AND spras = 'D'&lt;/P&gt;&lt;P&gt;AND adzhl = t_cabnt-adzhl.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope your problem is solved now.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Pranjali&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Nov 2010 11:20:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dump-on-single-row-subquery/m-p/7504692#M1558850</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-11-17T11:20:00Z</dc:date>
    </item>
    <item>
      <title>Re: Dump on single-row subquery</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dump-on-single-row-subquery/m-p/7504693#M1558851</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Abhishek,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it really works. Does that mean, the subquery is executed before the outer select?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Daniel Brack on Nov 17, 2010 1:18 PM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't get the dump with your version, but I don't think it works correct, because when I replace MAX by MIN it selects a totally different record (with other value for ATINN for example).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Nov 2010 11:25:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dump-on-single-row-subquery/m-p/7504693#M1558851</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-11-17T11:25:15Z</dc:date>
    </item>
    <item>
      <title>Re: Dump on single-row subquery</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dump-on-single-row-subquery/m-p/7504694#M1558852</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;/P&gt;&lt;P&gt;My proposal of get max is(there is no need to write subquery):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
 TABLES: cabnt.

 SELECT * FROM cabnt
   UP TO 1 ROWS
   WHERE atinn =  '00000000XX'  AND spras = 'D'
   ORDER BY adzhl DESCENDING.
 ENDSELECT.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Daniel Duras on Nov 17, 2010 12:43 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Nov 2010 11:42:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dump-on-single-row-subquery/m-p/7504694#M1558852</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-11-17T11:42:45Z</dc:date>
    </item>
    <item>
      <title>Re: Dump on single-row subquery</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dump-on-single-row-subquery/m-p/7504695#M1558853</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Daniel,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;your solution would have been my alternative, if I didn't get it work with the subquery :-). How about performance? Subquery vs. up to n rows?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can't believe, but I got another solution:&lt;/P&gt;&lt;P&gt;SELECT SINGLE atbez FROM cabnt &lt;STRONG&gt;as c&lt;/STRONG&gt; INTO atbez&lt;/P&gt;&lt;P&gt;WHERE atinn = '0000002134'&lt;/P&gt;&lt;P&gt;AND spras = 'D'&lt;/P&gt;&lt;P&gt;AND adzhl =&lt;/P&gt;&lt;P&gt;( SELECT MAX( adzhl ) FROM cabnt WHERE atinn = c~atinn&lt;/P&gt;&lt;P&gt;AND spras = 'D'&lt;/P&gt;&lt;P&gt;GROUP BY atinn spras ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I just defined an alias ("as c" ) for the outer select and changed the where clause of the subquery to that alias with the result, that the dump doesn't occur anymore.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Nov 2010 12:26:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dump-on-single-row-subquery/m-p/7504695#M1558853</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-11-17T12:26:49Z</dc:date>
    </item>
    <item>
      <title>Re: Dump on single-row subquery</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dump-on-single-row-subquery/m-p/7504696#M1558854</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Daniel,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think, that table cabnt won't have many rows on your production server. Check it out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Furthemore you can make some combinations of this code f.e. remove DB sorting and use ABAP SORT BY statement.&lt;/P&gt;&lt;P&gt;It should be faster I think. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Moreover&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
SELECT var
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is faster than &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
SELECT *
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But like I said before this table is quite small ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards, Daniel.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Nov 2010 12:45:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dump-on-single-row-subquery/m-p/7504696#M1558854</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-11-17T12:45:47Z</dc:date>
    </item>
  </channel>
</rss>

