Re: PL/SQL: exception handling

From: Peter Mapson <mapsonp_at_ois.com.au>
Date: 1996/03/02
Message-ID: <4h961i$4h4_at_eagle.ois.com.au>#1/1


chuckh_at_ix.netcom.com (Chuck Hamilton) wrote:

>I have a PL/SQL program with 5 major sections to it. The exception
>handling for each is identical. If I get an exception in any section,
>I simply want it to print the sqlcode, exit that section, and proceed
>with the next. If I simply define 1 exception handler for the entire
>program though, any exception drops me completely out of the program.
>Is there a way to define the exception handler once and have it apply
>to all 5 sections in the manner I've described?

You might like to try something along the following lines:

declare
  x number ;
begin
  for x := 1 .. 5 loop
    begin

       begin
           if x = 1 then
              -- section 1 body
           end if ;
       end ;
       begin
           if x = 2 then
              -- section 2 body
           end if ;
       end ;
       -- and so on for each section
     exception
         when others then 
              -- define your global exception handler
              -- for all 5 blocks here
      end ;
  • if the exception handler fires, you'll end up here, and just
  • loop around and execute the next section end loop ; end ;
Received on Sat Mar 02 1996 - 00:00:00 CET

Original text of this message