<?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>Question Re: Need help on 'IF' statement in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/need-help-on-if-statement/qaa-p/13830610#M4861453</link>
    <description>&lt;P&gt;Oh my god it works!! Thank you so much for helping out. Appreciate it. &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 12 Dec 2013 21:04:50 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2013-12-12T21:04:50Z</dc:date>
    <item>
      <title>Need help on 'IF' statement</title>
      <link>https://community.sap.com/t5/technology-q-a/need-help-on-if-statement/qaq-p/13830608</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I have error when running the following script:&lt;/P&gt;
&lt;DIV class="codehilite"&gt;&lt;PRE&gt;&lt;SPAN class="n"&gt;IF&lt;/SPAN&gt; &lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="nb"&gt;select&lt;/SPAN&gt; &lt;SPAN class="n"&gt;rest_name&lt;/SPAN&gt; &lt;SPAN class="n"&gt;from&lt;/SPAN&gt; &lt;SPAN class="n"&gt;table&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;rest_def&lt;/SPAN&gt;&lt;SPAN class="p"&gt;)&lt;/SPAN&gt; &lt;SPAN class="o"&gt;&amp;lt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="s"&gt;'TESTING'&lt;/SPAN&gt; &lt;SPAN class="n"&gt;THEN&lt;/SPAN&gt;
    &lt;SPAN class="n"&gt;RETURN&lt;/SPAN&gt;
  &lt;SPAN class="n"&gt;ELSE&lt;/SPAN&gt;
    &lt;SPAN class="n"&gt;SELECT&lt;/SPAN&gt; &lt;SPAN class="n"&gt;net_sls_ttl&lt;/SPAN&gt; 
    &lt;SPAN class="n"&gt;FROM&lt;/SPAN&gt; &lt;SPAN class="n"&gt;table&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;dly_sys_ttl&lt;/SPAN&gt;
    &lt;SPAN class="n"&gt;WHERE&lt;/SPAN&gt; &lt;SPAN class="n"&gt;cast&lt;/SPAN&gt;&lt;SPAN class="p"&gt;((&lt;/SPAN&gt;&lt;SPAN class="n"&gt;getDate&lt;/SPAN&gt;&lt;SPAN class="p"&gt;())&lt;/SPAN&gt; &lt;SPAN class="n"&gt;As&lt;/SPAN&gt; &lt;SPAN class="n"&gt;Date&lt;/SPAN&gt;&lt;SPAN class="p"&gt;)&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="n"&gt;cast&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;dly_sys_ttl&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;business_date&lt;/SPAN&gt; &lt;SPAN class="n"&gt;As&lt;/SPAN&gt; &lt;SPAN class="n"&gt;Date&lt;/SPAN&gt;&lt;SPAN class="p"&gt;);&lt;/SPAN&gt;

    &lt;SPAN class="n"&gt;OUTPUT&lt;/SPAN&gt; &lt;SPAN class="n"&gt;TO&lt;/SPAN&gt; &lt;SPAN class="n"&gt;&lt;span class="lia-unicode-emoji" title=":anguished_face:"&gt;😧&lt;/span&gt;&lt;/SPAN&gt;&lt;SPAN class="o"&gt;\\&lt;/SPAN&gt;&lt;SPAN class="n"&gt;TimeCard&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;csv&lt;/SPAN&gt;
    &lt;SPAN class="n"&gt;FORMAT&lt;/SPAN&gt; &lt;SPAN class="n"&gt;TEXT&lt;/SPAN&gt;&lt;SPAN class="p"&gt;;&lt;/SPAN&gt;

&lt;SPAN class="k"&gt;END&lt;/SPAN&gt; &lt;SPAN class="n"&gt;IF&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/DIV&gt;


&lt;P&gt;The error is&lt;/P&gt;
&lt;P&gt;"Could not execute statement. Syntax error near 'OUTPUT' on line 8. SQLCODE=-131. ODBC 3 STATE="42000" Line 1 column 5"&lt;/P&gt;
&lt;P&gt;However, there is no error if I remove the IF statement. The text file can be exported if I only run these:&lt;/P&gt;
&lt;DIV class="codehilite"&gt;&lt;PRE&gt;&lt;SPAN class="n"&gt;SELECT&lt;/SPAN&gt; &lt;SPAN class="n"&gt;net_sls_ttl&lt;/SPAN&gt; 
&lt;SPAN class="n"&gt;FROM&lt;/SPAN&gt; &lt;SPAN class="n"&gt;table&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;dly_sys_ttl&lt;/SPAN&gt;
&lt;SPAN class="n"&gt;WHERE&lt;/SPAN&gt; &lt;SPAN class="n"&gt;cast&lt;/SPAN&gt;&lt;SPAN class="p"&gt;((&lt;/SPAN&gt;&lt;SPAN class="n"&gt;getDate&lt;/SPAN&gt;&lt;SPAN class="p"&gt;())&lt;/SPAN&gt; &lt;SPAN class="n"&gt;As&lt;/SPAN&gt; &lt;SPAN class="n"&gt;Date&lt;/SPAN&gt;&lt;SPAN class="p"&gt;)&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="n"&gt;cast&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;dly_sys_ttl&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;business_date&lt;/SPAN&gt; &lt;SPAN class="n"&gt;As&lt;/SPAN&gt; &lt;SPAN class="n"&gt;Date&lt;/SPAN&gt;&lt;SPAN class="p"&gt;);&lt;/SPAN&gt;

&lt;SPAN class="n"&gt;OUTPUT&lt;/SPAN&gt; &lt;SPAN class="n"&gt;TO&lt;/SPAN&gt; &lt;SPAN class="n"&gt;&lt;span class="lia-unicode-emoji" title=":anguished_face:"&gt;😧&lt;/span&gt;&lt;/SPAN&gt;&lt;SPAN class="o"&gt;\\&lt;/SPAN&gt;&lt;SPAN class="n"&gt;TimeCard&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;csv&lt;/SPAN&gt;
&lt;SPAN class="n"&gt;FORMAT&lt;/SPAN&gt; &lt;SPAN class="n"&gt;TEXT&lt;/SPAN&gt;&lt;SPAN class="p"&gt;;&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/DIV&gt;


&lt;P&gt;Please help &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Dec 2013 05:37:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/need-help-on-if-statement/qaq-p/13830608</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-12-12T05:37:27Z</dc:date>
    </item>
    <item>
      <title>Re: Need help on 'IF' statement</title>
      <link>https://community.sap.com/t5/technology-q-a/need-help-on-if-statement/qaa-p/13830609#M4861452</link>
      <description>&lt;P&gt;OUTPUT is an ISQL command, not a SQL statement, and as such, cannot be used within procedures and code blocks - and the IF statement makes your list of statements a code block. (In contrast, your list of statements without the IF statement is &lt;EM&gt;not&lt;/EM&gt; a code block, i.e. each statement is sent to the database engine each on its own (here's only one: the SELECT statement), and then DBISQL processes the OUTPUT command itself.)&lt;/P&gt;
&lt;P&gt;Therefore you need to use the UNLOAD statement instead of OUTPUT - cf. this related question:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://sqlanywhere-forum.sap.com/questions/10643"&gt;OUTPUT does not work in procedures/events&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Thu, 12 Dec 2013 06:12:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/need-help-on-if-statement/qaa-p/13830609#M4861452</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2013-12-12T06:12:24Z</dc:date>
    </item>
    <item>
      <title>Re: Need help on 'IF' statement</title>
      <link>https://community.sap.com/t5/technology-q-a/need-help-on-if-statement/qaa-p/13830610#M4861453</link>
      <description>&lt;P&gt;Oh my god it works!! Thank you so much for helping out. Appreciate it. &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Dec 2013 21:04:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/need-help-on-if-statement/qaa-p/13830610#M4861453</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-12-12T21:04:50Z</dc:date>
    </item>
  </channel>
</rss>

