Re: PL/SQL

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: 1997/12/23
Message-ID: <349f1901.25154990_at_inet16>#1/1


On Tue, 23 Dec 1997 00:04:59 -0000, "Steven Jelfs" <S.Jelfs_at_btinternet.com> wrote:

>
>Supian Zainuddin wrote in message <349DC3F6.DC1190A5_at_ubs.com>...
>>I'm really not sure how will the exception be caught here...
>>
>>begin
>>
>> delete from table_test ......
>> insert into table_test .........
>>
>> and then a call to a procedure say test ( bla, bla );
>>
>>exception
>>
>> when others ......
>>
>>end;
>>
>>procedure test ( bla, bla )
>>is
>>begin
>> do something that triggers exception
>>end;
>>-- no exception handling is done in this procedure
>>
>>
>>the question;
>>
>>Will the uncaught raised exception in procedure test be caught in the
>>calling routine or not ?
>

Yes it will, exceptions are handled at the lowest level they are caught at and propagate up to the next level and may be caught and handled there. So, in the above example, if TEST generates an exception, the anonymous block that called it will catch it....

for example:

SQL> create or replace procedure test
  2 as
  3 begin
  4 raise program_error;
  5 end;
  6 /  

Procedure created.  

SQL> create table foo ( x int );  

Table created.  

SQL> set serveroutput on
SQL> begin

  2          insert into foo values (1);
  3          delete from foo;
  4          test;
  5  exception
  6          when others then dbms_output.put_line( 'Caught it' );
  7 end;
  8 /
Caught it  

PL/SQL procedure successfully completed.

No error, caught and dealt with the exception.

>htp.p('No');
>htp.nl;
>
>
>>
>>Appreciate some help.
>>
>>cheers, Supian
>>
>>
>
>end;
>
>-- SJ
>
 

Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Bethesda MD  

http://govt.us.oracle.com/ -- downloadable utilities  



Opinions are mine and do not necessarily reflect those of Oracle Corporation  

Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Tue Dec 23 1997 - 00:00:00 CET

Original text of this message