<?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: Exit command in SQL script in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/exit-command-in-sql-script/qaa-p/9275224#M3294427</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks alot Ravi and Jody!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 21 Feb 2013 14:04:56 GMT</pubDate>
    <dc:creator>arpitasethi</dc:creator>
    <dc:date>2013-02-21T14:04:56Z</dc:date>
    <item>
      <title>Exit command in SQL script</title>
      <link>https://community.sap.com/t5/technology-q-a/exit-command-in-sql-script/qaq-p/9275212</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there an 'Exit' like command in SQL script (for script based calculation view)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks and Regards,&lt;/P&gt;&lt;P&gt;Arpita&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Feb 2013 10:01:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/exit-command-in-sql-script/qaq-p/9275212</guid>
      <dc:creator>arpitasethi</dc:creator>
      <dc:date>2013-02-18T10:01:49Z</dc:date>
    </item>
    <item>
      <title>Re: Exit command in SQL script</title>
      <link>https://community.sap.com/t5/technology-q-a/exit-command-in-sql-script/qaa-p/9275213#M3294416</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Arpita,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't think there is any EXIT as such, but if you are using LOOPS (WHILE or IF) with a condition, then you can always make the condition false for the loop to complete.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For ex: if you have while loop with &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; WHILE v_val &amp;lt; 50 DO&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; END WHILE;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the loop you can always set the v_val to 50 when you want to exit the loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is this what you are looking for or is there something else.&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;Ravi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Feb 2013 10:23:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/exit-command-in-sql-script/qaa-p/9275213#M3294416</guid>
      <dc:creator>Ravi_Channe</dc:creator>
      <dc:date>2013-02-18T10:23:03Z</dc:date>
    </item>
    <item>
      <title>Re: Exit command in SQL script</title>
      <link>https://community.sap.com/t5/technology-q-a/exit-command-in-sql-script/qaa-p/9275214#M3294417</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ravi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wanted something like - &lt;/P&gt;&lt;P&gt;If x is null then&lt;/P&gt;&lt;P&gt;exit;&lt;/P&gt;&lt;P&gt;end if;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ofcourse, I can put my code in the other condition for if, if there is no exit.&lt;/P&gt;&lt;P&gt;I just wanted to keep it clean.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyway, thanks for the input!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Arpita&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Feb 2013 10:28:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/exit-command-in-sql-script/qaa-p/9275214#M3294417</guid>
      <dc:creator>arpitasethi</dc:creator>
      <dc:date>2013-02-18T10:28:25Z</dc:date>
    </item>
    <item>
      <title>Re: Exit command in SQL script</title>
      <link>https://community.sap.com/t5/technology-q-a/exit-command-in-sql-script/qaa-p/9275215#M3294418</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just to add there are BREAK &amp;amp; CONTINUE statements that you could use to exit from loops - page 43 in &lt;A href="http://help.sap.com/hana/hana_dev_sqlscript_en.pdf"&gt;http://help.sap.com/hana/hana_dev_sqlscript_en.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Anooj&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Feb 2013 11:35:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/exit-command-in-sql-script/qaa-p/9275215#M3294418</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-02-18T11:35:17Z</dc:date>
    </item>
    <item>
      <title>Re: Exit command in SQL script</title>
      <link>https://community.sap.com/t5/technology-q-a/exit-command-in-sql-script/qaa-p/9275216#M3294419</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Anooj,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Welcome back.. &lt;SPAN __jive_emoticon_name="happy" __jive_macro_name="emoticon" class="jive_macro jive_macro_emoticon jive_emote" src="https://community.sap.com/1214/images/emoticons/happy.gif"&gt;&lt;/SPAN&gt;. Missed your expert comments last few days.&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;Ravi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Feb 2013 11:50:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/exit-command-in-sql-script/qaa-p/9275216#M3294419</guid>
      <dc:creator>Ravi_Channe</dc:creator>
      <dc:date>2013-02-18T11:50:20Z</dc:date>
    </item>
    <item>
      <title>Re: Exit command in SQL script</title>
      <link>https://community.sap.com/t5/technology-q-a/exit-command-in-sql-script/qaa-p/9275217#M3294420</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Ravi &lt;SPAN __jive_emoticon_name="happy" __jive_macro_name="emoticon" class="jive_macro jive_emote" src="https://community.sap.com/1214/images/emoticons/happy.gif"&gt;&lt;/SPAN&gt; Hope you doing well!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Feb 2013 13:05:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/exit-command-in-sql-script/qaa-p/9275217#M3294420</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-02-18T13:05:45Z</dc:date>
    </item>
    <item>
      <title>Re: Exit command in SQL script</title>
      <link>https://community.sap.com/t5/technology-q-a/exit-command-in-sql-script/qaa-p/9275218#M3294421</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Arpita, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One further comment. I'm not exactly sure what EXIT does, but my suspicion is that it's similar to 'return' in Java and other languages. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One common application programming requirement is data validation, with a return if required conditions aren't met - i.e. checking input data. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One solution in SQLScript is as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) At the beginning of your code (after BEGIN), declare a error condition:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DECLARE MYCOND CONDITION FOR SQL_ERROR_CODE 10001; -- example&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) In your code, check required condition. if not met, signal your condition:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF (requested_start &amp;gt;= requested_end) THEN&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SIGNAL MYCOND SET MESSAGE_TEXT = 'Requested start date must be before requested end date.';&lt;/P&gt;&lt;P&gt;END IF;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At this point an exception will be thrown with the error msg you specify. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How do you handle such exceptions gracefully?&amp;nbsp; After your condition declaration, declare an exit handler. The code following the exit handler declaration is run each time an exception is encountered, giving you an opportunity to handle exceptions gracefully. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DECLARE EXIT HANDLER FOR SQLEXCEPTION&lt;/P&gt;&lt;P&gt;SELECT * FROM DEBUG_MSG;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, the entire snippet in my case (requested_start and requested_end are input parameters):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-- use this to signal exceptions as required&lt;/P&gt;&lt;P&gt;DECLARE MYCOND CONDITION FOR SQL_ERROR_CODE 10001;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-- following catches exceptions and runs the code immediately following&lt;/P&gt;&lt;P&gt;DECLARE EXIT HANDLER FOR SQLEXCEPTION&lt;/P&gt;&lt;P&gt;SELECT * FROM DEBUG_MSG;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-- check input dates.&lt;/P&gt;&lt;P&gt;-- check that dates are further from each other than requested duration.&lt;/P&gt;&lt;P&gt;IF (requested_start &amp;gt;= requested_end) THEN&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SIGNAL MYCOND SET MESSAGE_TEXT = 'Requested start date must be before requested end date.';&lt;/P&gt;&lt;P&gt;END IF;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Feb 2013 19:54:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/exit-command-in-sql-script/qaa-p/9275218#M3294421</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-02-18T19:54:46Z</dc:date>
    </item>
    <item>
      <title>Re: Exit command in SQL script</title>
      <link>https://community.sap.com/t5/technology-q-a/exit-command-in-sql-script/qaa-p/9275219#M3294422</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This concept, of course, could also be used inside of a loop, etc. &lt;SPAN __jive_emoticon_name="happy" __jive_macro_name="emoticon" class="jive_macro jive_emote" src="https://community.sap.com/1214/images/emoticons/happy.gif"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Feb 2013 19:55:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/exit-command-in-sql-script/qaa-p/9275219#M3294422</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-02-18T19:55:50Z</dc:date>
    </item>
    <item>
      <title>Re: Exit command in SQL script</title>
      <link>https://community.sap.com/t5/technology-q-a/exit-command-in-sql-script/qaa-p/9275220#M3294423</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jody,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it possible to have an exit handler for a condition like this - &lt;/P&gt;&lt;P&gt;:var = 1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This way, when ever I have to call exit handler, I can set the variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks alot!&lt;/P&gt;&lt;P&gt;Arpita&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Feb 2013 11:17:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/exit-command-in-sql-script/qaa-p/9275220#M3294423</guid>
      <dc:creator>arpitasethi</dc:creator>
      <dc:date>2013-02-20T11:17:31Z</dc:date>
    </item>
    <item>
      <title>Re: Exit command in SQL script</title>
      <link>https://community.sap.com/t5/technology-q-a/exit-command-in-sql-script/qaa-p/9275221#M3294424</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Arpita,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you run the following procedure, you'll get an exception as expected. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you uncomment the two commented lines, you'll see that the exception is handled and that a value is stored in a scalar output variable. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let me know if this helps. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Jody&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DROP PROCEDURE TESTP;&lt;BR /&gt;CREATE PROCEDURE TESTP(OUT a INTEGER) AS&lt;/P&gt;&lt;P&gt;BEGIN&lt;BR /&gt; DECLARE MYCOND CONDITION FOR SQL_ERROR_CODE 10001;&lt;BR /&gt; &lt;BR /&gt; -- DECLARE EXIT HANDLER FOR SQLEXCEPTION&lt;BR /&gt; -- SELECT 5 INTO a FROM DUMMY; &lt;BR /&gt; &lt;BR /&gt; SIGNAL MYCOND SET MESSAGE_TEXT = 'Enter a message here';&lt;BR /&gt;END;&lt;/P&gt;&lt;P&gt;CALL TESTP(?);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Feb 2013 17:53:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/exit-command-in-sql-script/qaa-p/9275221#M3294424</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-02-20T17:53:09Z</dc:date>
    </item>
    <item>
      <title>Re: Exit command in SQL script</title>
      <link>https://community.sap.com/t5/technology-q-a/exit-command-in-sql-script/qaa-p/9275222#M3294425</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jody,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I guess I was not clear..&lt;/P&gt;&lt;P&gt;I want to raise an exception based on the value in a variable and not the other way round!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Arpita&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Feb 2013 04:13:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/exit-command-in-sql-script/qaa-p/9275222#M3294425</guid>
      <dc:creator>arpitasethi</dc:creator>
      <dc:date>2013-02-21T04:13:15Z</dc:date>
    </item>
    <item>
      <title>Re: Exit command in SQL script</title>
      <link>https://community.sap.com/t5/technology-q-a/exit-command-in-sql-script/qaa-p/9275223#M3294426</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Arpita,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think Jody already mentioned that. You can check the value of the variable and can SIGNAL the exception.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12px; background-color: #ffffff; color: #333333;"&gt;IF (variable = value) THEN&lt;/P&gt;&lt;P style="font-size: 12px; background-color: #ffffff; color: #333333;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SIGNAL MYCOND SET MESSAGE_TEXT = 'Requested start date must be before requested end date.';&lt;/P&gt;&lt;P style="font-size: 12px; background-color: #ffffff; color: #333333;"&gt;END IF;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Surprisingly, I could not find any information on SIGNAL or Declaring custom exceptions (except for SQL exception in sample codes) in the SQL script guide.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is quite an interesting and much awaited feature in SQL script and I am keen to know more about it.&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;Ravi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Feb 2013 13:02:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/exit-command-in-sql-script/qaa-p/9275223#M3294426</guid>
      <dc:creator>Ravi_Channe</dc:creator>
      <dc:date>2013-02-21T13:02:24Z</dc:date>
    </item>
    <item>
      <title>Re: Exit command in SQL script</title>
      <link>https://community.sap.com/t5/technology-q-a/exit-command-in-sql-script/qaa-p/9275224#M3294427</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks alot Ravi and Jody!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Feb 2013 14:04:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/exit-command-in-sql-script/qaa-p/9275224#M3294427</guid>
      <dc:creator>arpitasethi</dc:creator>
      <dc:date>2013-02-21T14:04:56Z</dc:date>
    </item>
    <item>
      <title>Re: Exit command in SQL script</title>
      <link>https://community.sap.com/t5/technology-q-a/exit-command-in-sql-script/qaa-p/9275225#M3294428</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes!&lt;/P&gt;&lt;P&gt;Stupid me! Took sometime to actually understand.. Thanks Ravi!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it possible to not set the message? I do not want to throw an error message, just exit.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Feb 2013 14:09:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/exit-command-in-sql-script/qaa-p/9275225#M3294428</guid>
      <dc:creator>arpitasethi</dc:creator>
      <dc:date>2013-02-21T14:09:38Z</dc:date>
    </item>
    <item>
      <title>Re: Exit command in SQL script</title>
      <link>https://community.sap.com/t5/technology-q-a/exit-command-in-sql-script/qaa-p/9275226#M3294429</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ravindra,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes unfortunately official documentation on this is lacking but looks like it's in the works. I had the fortune of learning the details from a colleague (credit to Adam Baryla). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Jody&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Feb 2013 18:36:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/exit-command-in-sql-script/qaa-p/9275226#M3294429</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-02-21T18:36:05Z</dc:date>
    </item>
    <item>
      <title>Re: Exit command in SQL script</title>
      <link>https://community.sap.com/t5/technology-q-a/exit-command-in-sql-script/qaa-p/9275227#M3294430</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jody,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not able to test right now, but the signal function will also work if I donot want to set an error message?&lt;/P&gt;&lt;P&gt;Basically, I do not want any user action or notification, just simple return in the logic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks alot so far!!!&lt;/P&gt;&lt;P&gt;Arpita&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Feb 2013 06:35:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/exit-command-in-sql-script/qaa-p/9275227#M3294430</guid>
      <dc:creator>arpitasethi</dc:creator>
      <dc:date>2013-02-22T06:35:17Z</dc:date>
    </item>
    <item>
      <title>Re: Exit command in SQL script</title>
      <link>https://community.sap.com/t5/technology-q-a/exit-command-in-sql-script/qaa-p/9275228#M3294431</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In that case BREAK will also work.&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;Ravi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Feb 2013 08:40:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/exit-command-in-sql-script/qaa-p/9275228#M3294431</guid>
      <dc:creator>Ravi_Channe</dc:creator>
      <dc:date>2013-02-22T08:40:09Z</dc:date>
    </item>
    <item>
      <title>Re: Exit command in SQL script</title>
      <link>https://community.sap.com/t5/technology-q-a/exit-command-in-sql-script/qaa-p/9275229#M3294432</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;BREAK will get you out of a loop, but subsequent code will execute. Signaling your condition will stop execution of your procedure. If you don't want error messages, etc - just make sure to include the exit handler syntax above, and just don't execute any SQL following that exit handler. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try it out once you get access to test system and let me know if you have any questions. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Feb 2013 17:35:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/exit-command-in-sql-script/qaa-p/9275229#M3294432</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-02-22T17:35:44Z</dc:date>
    </item>
    <item>
      <title>Re: Exit command in SQL script</title>
      <link>https://community.sap.com/t5/technology-q-a/exit-command-in-sql-script/qaa-p/9275230#M3294433</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi folks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just a follow up that I found a bit more documentation on exception handling underneath the trigger section of the HANA SQL guide for SP5 (not the SQLScript guide as one might expect). Check out page 99 of the guide. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another useful feature of this functionality is RESIGNAL. Example use case:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) You want to stop execution of a stored procedure under certain circumstances but don't need to throw an error (i.e. you need something like 'return' in Java).&lt;/P&gt;&lt;P&gt;2) In order to implement this, you signal a custom condition that you defined call MYCOND, and you also defined an EXIT_HANDLER that handles exceptions.&lt;/P&gt;&lt;P&gt;3) You want to make sure that other SQL exceptions still get thrown (i.e. you don't want them 'caught up' in your generic exit handler. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this case, you can do something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DECLARE MYCOND CONDITION FOR SQL_ERROR_CODE 10001&lt;SPAN style="font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DECLARE EXIT HANDLER FOR SQLEXCEPTION &lt;/P&gt;&lt;P&gt;IF (::SQL_ERROR_CODE != 10001) THEN&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RESIGNAL;&lt;/P&gt;&lt;P&gt;ELSE&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -- do whatever else you might want to do once your custom exception is caught. Kind of like 'finally' following a try/catch block&lt;/P&gt;&lt;P&gt;END;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-- in your proc, when you want to stop execution because, for example, you have your answer, signal your exception:&lt;/P&gt;&lt;P&gt;SIGNAL MYCOND SET MESSAGE_TEXT = 'If this exception is handled, this message won't make it to the client';&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Apr 2013 04:41:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/exit-command-in-sql-script/qaa-p/9275230#M3294433</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-04-04T04:41:44Z</dc:date>
    </item>
    <item>
      <title>Re: Exit command in SQL script</title>
      <link>https://community.sap.com/t5/technology-q-a/exit-command-in-sql-script/qaa-p/9275231#M3294434</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;After messing around with this a bit, there's a much cleaner approach:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DECLARE EXIT HANDLER FOR MYCOND&lt;/P&gt;&lt;P&gt;-- enter whatever code you want executed if any&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All normal SQL exceptions that might be thrown will still be thrown without getting caught in your handler. No need for cludgy IF/ELSE.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Apr 2013 05:50:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/exit-command-in-sql-script/qaa-p/9275231#M3294434</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-04-05T05:50:24Z</dc:date>
    </item>
  </channel>
</rss>

