<?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 Terminating A SP Programmatically in Developers</title>
    <link>https://communities.sas.com/t5/Developers/Terminating-A-SP-Programmatically/m-p/2982#M1670</link>
    <description>All:&lt;BR /&gt;
&lt;BR /&gt;
I'm sure others in this forum have already successfully dealt with this issue. What is the best/proper way to conditionally terminate a SP and deliver a message to the user ?&lt;BR /&gt;
&lt;BR /&gt;
The sample code below does terminate the SP based on a query not returning any rows, but we still receive a stored process message about abnormal termination after the message from the program itself.&lt;BR /&gt;
&lt;BR /&gt;
To get around this, we "eliminated" the SP error message by "cheating" we changed background color to black. &lt;BR /&gt;
&lt;BR /&gt;
There has to be a better, more graceful way to do condition/exception handling in stored processes.&lt;BR /&gt;
&lt;BR /&gt;
Thank You.&lt;BR /&gt;
&lt;BR /&gt;
-Gerry&lt;BR /&gt;
&lt;BR /&gt;
Gerard T. Pauline&lt;BR /&gt;
Mgr, Internet/DB Applications&lt;BR /&gt;
Computer Systems, DoIT&lt;BR /&gt;
Pace University&lt;BR /&gt;
&lt;BR /&gt;
========================================================&lt;BR /&gt;
&lt;BR /&gt;
%Macro ROWS (DS) ;&lt;BR /&gt;
&lt;BR /&gt;
  %Global DSID NLOBSF RC ID ;&lt;BR /&gt;
&lt;BR /&gt;
  %Let DSID = %Sysfunc(Open(&amp;amp;DS));&lt;BR /&gt;
&lt;BR /&gt;
  %If (&amp;amp;DSID) %Then &lt;BR /&gt;
     %Do ;&lt;BR /&gt;
       %Let ROWS = %Sysfunc(Attrn(&amp;amp;DSID, NLOBSF)) ;&lt;BR /&gt;
       %Let RC   = %Sysfunc(Close(&amp;amp;DSID)) ;&lt;BR /&gt;
     %End ;&lt;BR /&gt;
&lt;BR /&gt;
  %If (&amp;amp;ROWS = 0) %Then &lt;BR /&gt;
     %Do ;&lt;BR /&gt;
        Data _NULL_ ;&lt;BR /&gt;
          File _WEBOUT ;&lt;BR /&gt;
          Put '' /&lt;BR /&gt;
              '&lt;TITLE&gt;No Data Found !'                              /                            &amp;lt;br&amp;gt;
              '&lt;/TITLE&gt;&lt;P&gt;'                          / ;&lt;BR /&gt;
          Put '&lt;TABLE&gt;'                                                         /&lt;BR /&gt;
              '&lt;TBODY&gt;&lt;TR&gt;'                                                            /&lt;BR /&gt;
              '&lt;TD style="color: red"&gt;'                                        /&lt;BR /&gt;
              '&lt;H1&gt;    There was no data found that satisfied the search '      /&lt;BR /&gt;
              'conditions specified !&lt;/H1&gt;&lt;/TD&gt;'                                /&lt;BR /&gt;
              '&lt;/TR&gt;'                                                           /&lt;BR /&gt;
              '&lt;/TBODY&gt;&lt;/TABLE&gt;'                                                        / ;&lt;BR /&gt;
          Put '&lt;/P&gt;&lt;P&gt;'                                               / ;&lt;BR /&gt;
		  &lt;BR /&gt;
          Call Execute ('EndSAS ;') ;&lt;BR /&gt;
          Call Execute ('%Str(;) ;') ;&lt;BR /&gt;
        Run ; &lt;BR /&gt;
     %End ;&lt;BR /&gt;
    %Else&lt;BR /&gt;
     %Do ;&lt;BR /&gt;
        Data _NULL_ ;&lt;BR /&gt;
          File _WEBOUT ;&lt;BR /&gt;
          Put '' /&lt;BR /&gt;
              '&lt;TITLE&gt;Data Found !&lt;/TITLE&gt;&lt;/P&gt;&lt;P&gt;'         / ;&lt;BR /&gt;
          Put '&lt;TABLE&gt;'                                                         /&lt;BR /&gt;
              '&lt;TBODY&gt;&lt;TR&gt;'                                                            /&lt;BR /&gt;
              '&lt;TD&gt;&lt;H1&gt;Data was found for this query -- '                       /&lt;BR /&gt;
              'YIPPEEEE !&lt;/H1&gt;&lt;/TD&gt;'                                            /&lt;BR /&gt;
              '&lt;/TR&gt;'                                                           /&lt;BR /&gt;
              '&lt;/TBODY&gt;&lt;/TABLE&gt;'                                                        / ;&lt;BR /&gt;
          Put '&lt;/P&gt;&lt;P&gt;'                                               / ;&lt;BR /&gt;
          Call Execute ('%Str(;) ;') ;&lt;BR /&gt;
        Run ; &lt;BR /&gt;
     %End ;&lt;BR /&gt;
&lt;BR /&gt;
 /*&lt;BR /&gt;
 &lt;BR /&gt;
  %If (&amp;amp;ROWS = 0) %Then&lt;BR /&gt;
     %Do ;&lt;BR /&gt;
        Data _NULL_ ;&lt;BR /&gt;
          PutLog 'There are no rows in the table !' ;&lt;BR /&gt;
          Call Execute ('EndSAS ;') ;&lt;BR /&gt;
          Call Execute ('%Str(;) ;') ;&lt;BR /&gt;
        Run ;&lt;BR /&gt;
     %End ;&lt;BR /&gt;
    %Else&lt;BR /&gt;
     %Do ;&lt;BR /&gt;
        Data _NULL_ ;&lt;BR /&gt;
          PutLog "There are &amp;amp;ROWS rows in the table" ;&lt;BR /&gt;
          Call Execute ('%Str(;) ;') ;&lt;BR /&gt;
        Run ;&lt;BR /&gt;
     %End ;&lt;BR /&gt;
  */&lt;BR /&gt;
&lt;BR /&gt;
%Mend ROWS ;&lt;BR /&gt;
&lt;BR /&gt;
Proc SQL ;&lt;BR /&gt;
  Create Table IsErika As&lt;BR /&gt;
  Select *&lt;BR /&gt;
    From SATURN.SPRIDEN&lt;BR /&gt;
   Where SPRIDEN_PIDM = &amp;amp;ID ;&lt;BR /&gt;
Quit ;&lt;BR /&gt;
&lt;BR /&gt;
%Rows (IsErika)&lt;BR /&gt;
&lt;BR /&gt;
Data _NULL_ ;&lt;BR /&gt;
  File _WEBOUT ;&lt;BR /&gt;
   Put '' /&lt;BR /&gt;
       '&lt;TITLE&gt;Data Found !&lt;/TITLE&gt;&lt;/P&gt;&lt;P&gt;'         / ;&lt;BR /&gt;
   Put '&lt;TABLE&gt;'                                                         /&lt;BR /&gt;
       '&lt;TBODY&gt;&lt;TR&gt;'                                                            /&lt;BR /&gt;
       '&lt;TD&gt;&lt;H1&gt;Processing continues-------------'                       /&lt;BR /&gt;
       'YIPPEEEE !&lt;/H1&gt;&lt;/TD&gt;'                                            /&lt;BR /&gt;
       '&lt;/TR&gt;'                                                           /&lt;BR /&gt;
       '&lt;/TBODY&gt;&lt;/TABLE&gt;'                                                        / ;&lt;BR /&gt;
   Put '&lt;/P&gt;&lt;P&gt;'                                               / ;&lt;BR /&gt;
  Call Execute ('%Str(;) ;') ;&lt;BR /&gt;
Run ;&lt;/P&gt;</description>
    <pubDate>Mon, 07 May 2007 15:50:29 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2007-05-07T15:50:29Z</dc:date>
    <item>
      <title>Terminating A SP Programmatically</title>
      <link>https://communities.sas.com/t5/Developers/Terminating-A-SP-Programmatically/m-p/2982#M1670</link>
      <description>All:&lt;BR /&gt;
&lt;BR /&gt;
I'm sure others in this forum have already successfully dealt with this issue. What is the best/proper way to conditionally terminate a SP and deliver a message to the user ?&lt;BR /&gt;
&lt;BR /&gt;
The sample code below does terminate the SP based on a query not returning any rows, but we still receive a stored process message about abnormal termination after the message from the program itself.&lt;BR /&gt;
&lt;BR /&gt;
To get around this, we "eliminated" the SP error message by "cheating" we changed background color to black. &lt;BR /&gt;
&lt;BR /&gt;
There has to be a better, more graceful way to do condition/exception handling in stored processes.&lt;BR /&gt;
&lt;BR /&gt;
Thank You.&lt;BR /&gt;
&lt;BR /&gt;
-Gerry&lt;BR /&gt;
&lt;BR /&gt;
Gerard T. Pauline&lt;BR /&gt;
Mgr, Internet/DB Applications&lt;BR /&gt;
Computer Systems, DoIT&lt;BR /&gt;
Pace University&lt;BR /&gt;
&lt;BR /&gt;
========================================================&lt;BR /&gt;
&lt;BR /&gt;
%Macro ROWS (DS) ;&lt;BR /&gt;
&lt;BR /&gt;
  %Global DSID NLOBSF RC ID ;&lt;BR /&gt;
&lt;BR /&gt;
  %Let DSID = %Sysfunc(Open(&amp;amp;DS));&lt;BR /&gt;
&lt;BR /&gt;
  %If (&amp;amp;DSID) %Then &lt;BR /&gt;
     %Do ;&lt;BR /&gt;
       %Let ROWS = %Sysfunc(Attrn(&amp;amp;DSID, NLOBSF)) ;&lt;BR /&gt;
       %Let RC   = %Sysfunc(Close(&amp;amp;DSID)) ;&lt;BR /&gt;
     %End ;&lt;BR /&gt;
&lt;BR /&gt;
  %If (&amp;amp;ROWS = 0) %Then &lt;BR /&gt;
     %Do ;&lt;BR /&gt;
        Data _NULL_ ;&lt;BR /&gt;
          File _WEBOUT ;&lt;BR /&gt;
          Put '' /&lt;BR /&gt;
              '&lt;TITLE&gt;No Data Found !'                              /                            &amp;lt;br&amp;gt;
              '&lt;/TITLE&gt;&lt;P&gt;'                          / ;&lt;BR /&gt;
          Put '&lt;TABLE&gt;'                                                         /&lt;BR /&gt;
              '&lt;TBODY&gt;&lt;TR&gt;'                                                            /&lt;BR /&gt;
              '&lt;TD style="color: red"&gt;'                                        /&lt;BR /&gt;
              '&lt;H1&gt;    There was no data found that satisfied the search '      /&lt;BR /&gt;
              'conditions specified !&lt;/H1&gt;&lt;/TD&gt;'                                /&lt;BR /&gt;
              '&lt;/TR&gt;'                                                           /&lt;BR /&gt;
              '&lt;/TBODY&gt;&lt;/TABLE&gt;'                                                        / ;&lt;BR /&gt;
          Put '&lt;/P&gt;&lt;P&gt;'                                               / ;&lt;BR /&gt;
		  &lt;BR /&gt;
          Call Execute ('EndSAS ;') ;&lt;BR /&gt;
          Call Execute ('%Str(;) ;') ;&lt;BR /&gt;
        Run ; &lt;BR /&gt;
     %End ;&lt;BR /&gt;
    %Else&lt;BR /&gt;
     %Do ;&lt;BR /&gt;
        Data _NULL_ ;&lt;BR /&gt;
          File _WEBOUT ;&lt;BR /&gt;
          Put '' /&lt;BR /&gt;
              '&lt;TITLE&gt;Data Found !&lt;/TITLE&gt;&lt;/P&gt;&lt;P&gt;'         / ;&lt;BR /&gt;
          Put '&lt;TABLE&gt;'                                                         /&lt;BR /&gt;
              '&lt;TBODY&gt;&lt;TR&gt;'                                                            /&lt;BR /&gt;
              '&lt;TD&gt;&lt;H1&gt;Data was found for this query -- '                       /&lt;BR /&gt;
              'YIPPEEEE !&lt;/H1&gt;&lt;/TD&gt;'                                            /&lt;BR /&gt;
              '&lt;/TR&gt;'                                                           /&lt;BR /&gt;
              '&lt;/TBODY&gt;&lt;/TABLE&gt;'                                                        / ;&lt;BR /&gt;
          Put '&lt;/P&gt;&lt;P&gt;'                                               / ;&lt;BR /&gt;
          Call Execute ('%Str(;) ;') ;&lt;BR /&gt;
        Run ; &lt;BR /&gt;
     %End ;&lt;BR /&gt;
&lt;BR /&gt;
 /*&lt;BR /&gt;
 &lt;BR /&gt;
  %If (&amp;amp;ROWS = 0) %Then&lt;BR /&gt;
     %Do ;&lt;BR /&gt;
        Data _NULL_ ;&lt;BR /&gt;
          PutLog 'There are no rows in the table !' ;&lt;BR /&gt;
          Call Execute ('EndSAS ;') ;&lt;BR /&gt;
          Call Execute ('%Str(;) ;') ;&lt;BR /&gt;
        Run ;&lt;BR /&gt;
     %End ;&lt;BR /&gt;
    %Else&lt;BR /&gt;
     %Do ;&lt;BR /&gt;
        Data _NULL_ ;&lt;BR /&gt;
          PutLog "There are &amp;amp;ROWS rows in the table" ;&lt;BR /&gt;
          Call Execute ('%Str(;) ;') ;&lt;BR /&gt;
        Run ;&lt;BR /&gt;
     %End ;&lt;BR /&gt;
  */&lt;BR /&gt;
&lt;BR /&gt;
%Mend ROWS ;&lt;BR /&gt;
&lt;BR /&gt;
Proc SQL ;&lt;BR /&gt;
  Create Table IsErika As&lt;BR /&gt;
  Select *&lt;BR /&gt;
    From SATURN.SPRIDEN&lt;BR /&gt;
   Where SPRIDEN_PIDM = &amp;amp;ID ;&lt;BR /&gt;
Quit ;&lt;BR /&gt;
&lt;BR /&gt;
%Rows (IsErika)&lt;BR /&gt;
&lt;BR /&gt;
Data _NULL_ ;&lt;BR /&gt;
  File _WEBOUT ;&lt;BR /&gt;
   Put '' /&lt;BR /&gt;
       '&lt;TITLE&gt;Data Found !&lt;/TITLE&gt;&lt;/P&gt;&lt;P&gt;'         / ;&lt;BR /&gt;
   Put '&lt;TABLE&gt;'                                                         /&lt;BR /&gt;
       '&lt;TBODY&gt;&lt;TR&gt;'                                                            /&lt;BR /&gt;
       '&lt;TD&gt;&lt;H1&gt;Processing continues-------------'                       /&lt;BR /&gt;
       'YIPPEEEE !&lt;/H1&gt;&lt;/TD&gt;'                                            /&lt;BR /&gt;
       '&lt;/TR&gt;'                                                           /&lt;BR /&gt;
       '&lt;/TBODY&gt;&lt;/TABLE&gt;'                                                        / ;&lt;BR /&gt;
   Put '&lt;/P&gt;&lt;P&gt;'                                               / ;&lt;BR /&gt;
  Call Execute ('%Str(;) ;') ;&lt;BR /&gt;
Run ;&lt;/P&gt;</description>
      <pubDate>Mon, 07 May 2007 15:50:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Terminating-A-SP-Programmatically/m-p/2982#M1670</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2007-05-07T15:50:29Z</dc:date>
    </item>
  </channel>
</rss>

