Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: quit or exit within PL/SQl
--------------B765B5C05BD9604456FA1946 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit
rob joss wrote:
> While running PL/SQL anonymous blocks , is there a package function > available that will let you force a quit or an exit to the operating > system prompt. I have tried DBMS_SQL.parse with an 'exit ' or 'quit' > and it generates an exception. > > These blocks are being run from within sqlplus on a unix server and I > want to force an exit for sqlplus when a critical package procedure > fails. If this can be done from within the package procedure which > inserts into an error log, then several PL/sql anonymous procedures do > > not need to be modified.
Dear Rob!
Just try it with
Sql*Plus> whenever sqlerror exit sql.sqlcode Sql*Plus> ... (your pl/sql block) Sql*Plus> ... exception when x raise_application_error(-20001,'YourErrortext',true); -- true only if you want the error stack Sql*Plus> ...end;
If there occurs the error, Sqlplus will end because of the whenever sqlerror setting.
Hope, this will help. ;-)
Tobias Hitzfeld
--------------B765B5C05BD9604456FA1946 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit
<HTML>
<BODY TEXT="#000000" BGCOLOR="#3333FF" LINK="#66FFFF" VLINK="#800040" ALINK="#FF0000">
<FONT COLOR="#FFFFFF">rob joss wrote:</FONT>
<BLOCKQUOTE TYPE=CITE><I><FONT COLOR="#66FFFF">While running PL/SQL anonymous
blocks , is there a package function</FONT></I>
<BR><I><FONT COLOR="#66FFFF">available that will let you force a quit or
an exit to the operating</FONT></I>
<BR><I><FONT COLOR="#66FFFF">system prompt. I have tried DBMS_SQL.parse
with an 'exit ' or 'quit'</FONT></I>
<BR><I><FONT COLOR="#66FFFF">and it generates an exception.</FONT></I><I><FONT COLOR="#66FFFF"></FONT></I>
<P><I><FONT COLOR="#66FFFF">These blocks are being run from within sqlplus
on a unix server and I</FONT></I>
<BR><I><FONT COLOR="#66FFFF">want to force an exit for sqlplus when a critical
package procedure</FONT></I>
<BR><I><FONT COLOR="#66FFFF">fails. If this can be done from within
the package procedure which</FONT></I>
<BR><I><FONT COLOR="#66FFFF">inserts into an error log, then several PL/sql
anonymous procedures do</FONT></I>
<BR><I><FONT COLOR="#66FFFF">not need to be modified.</FONT></I></BLOCKQUOTE>
<FONT COLOR="#FFFFFF">Dear Rob!</FONT>
<BR><FONT COLOR="#FFFFFF">Just try it with</FONT><FONT COLOR="#FFFFFF"></FONT>
<P><FONT COLOR="#FFFFFF">Sql*Plus> whenever sqlerror exit sql.sqlcode</FONT>
<BR><FONT COLOR="#FFFFFF">Sql*Plus> ... (your pl/sql block)</FONT>
<BR><FONT COLOR="#FFFFFF">Sql*Plus> ... exception when x raise_application_error(-20001,'Your
Errortext',true); -- true only if you want the error stack</FONT>
<BR><FONT COLOR="#FFFFFF">Sql*Plus> ...end;</FONT><FONT COLOR="#FFFFFF"></FONT>
<P><FONT COLOR="#FFFFFF">If there occurs the error, Sqlplus will end because
of the whenever sqlerror setting.</FONT><FONT COLOR="#FFFFFF"></FONT>
<P><FONT COLOR="#FFFFFF">Hope, this will help. ;-)</FONT><FONT COLOR="#FFFFFF"></FONT>
<P><FONT COLOR="#FFFFFF">Tobias Hitzfeld</FONT>
</BODY>
</HTML>
--------------B765B5C05BD9604456FA1946-- Received on Thu Jul 24 1997 - 00:00:00 CDT