DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: Exception at common for all procedures in a package

  1. #1
    Join Date
    Dec 2001
    Posts
    221
    Can we have it. one common exception for all the procedures in on package.

    e.g.

    the package below , both procedure will raise zero_divide exception . so i've to write it once.

    is it possible ??



    create or replace package pack1 as
    procedure p1;
    procedure p2;
    end;
    /


    create or replace package body pack1 as
    procedure p1 is
    n1 number;
    n2 number := 0;
    n3 number := 6;
    begin
    n1 := n3/n2;
    exception
    when zero_divide then
    dbms_output.put_line ('MESSAGE ALL');
    end;

    procedure p2 is
    n4 number;
    n5 number :=0 ;
    n6 number := 5;
    begin
    n4 := n6/n5;
    exception
    when zero_divide then
    dbms_output.put_line ('MESSAGE ALL');

    end;


    end;
    /
    Santosh Jadhav
    8i OCP DBA

  2. #2
    Join Date
    Feb 2002
    Location
    Dallas , Texas
    Posts
    158
    Hi,
    Hope it solves..

    create or replace package pack1 as
    procedure p1;
    procedure p2;
    procedure p3;
    end;
    /
    create or replace package body pack1 as
    procedure p1 is
    n1 number;
    n2 number := 0;
    n3 number := 6;
    begin
    n1 := n3/n2;
    exception
    when zero_divide then
    p3;
    end;

    procedure p2 is
    n4 number;
    n5 number :=0 ;
    n6 number := 5;
    begin
    n4 := n6/n5;
    exception
    when zero_divide then
    p3;
    end;

    procedure p3 is
    begin
    dbms_output.put_line ('MESSAGE ALL');
    end;

    end;
    /

    Take Care.

  3. #3
    Join Date
    Dec 2001
    Posts
    221
    any other way
    Santosh Jadhav
    8i OCP DBA

  4. #4
    Join Date
    Feb 2002
    Location
    Dallas , Texas
    Posts
    158
    Hi,

    I think you have to create a third object to refer it into the other 2 objects.

    Take Care.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width