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

Thread: Stop Proceed if error

  1. #1
    Join Date
    Oct 2000
    Posts
    250

    Stop Proceed if error

    Hi All,
    I have a package to run all the procedures.

    Basically, all the procedure performing the DML command.
    For instance, I have package as follow.

    PACKAGE test IS
    procedure A;
    procedure B;
    procedure C;
    procedure D;
    function run_all return boolean;
    END;

    PACKAGE BODY test IS
    procedure a is
    begin
    insert into ....
    WHEN OTHERS THEN
    ....

    end;

    procedure b is
    begin
    delete into ....
    WHEN OTHERS THEN
    ....

    end;

    procedure C is
    begin
    update into ....
    WHEN OTHERS THEN
    ....
    end;

    procedure d is
    begin
    insert into ....
    WHEN OTHERS THEN
    ....

    end;

    function run_all return boolean is
    begin
    a;
    b;
    c;
    d;
    end;

    Question : how to ask the program to exit if there is error on b without continuing the procedure c and d ? must I have a check for every single procedure ?


    Thanks

  2. #2
    Join Date
    May 2001
    Location
    San Francisco, California
    Posts
    511
    Define an OUT variable ERRCODE in each procedure. For example 0 for success 1 for failure.

    If the ERRCODE from the prevous procedure is > 0 then exit.
    Remember the Golden Rule - He who has the gold makes the rules!
    ===================
    Kris109
    Ph.D., OCP 8i, 9i, 10g, 11g DBA

  3. #3
    Join Date
    Nov 2003
    Location
    Ohio
    Posts
    51
    You could only handle specific errors in the individual procedures (use whatever exception handlers are appropriate rather than a generic "when others"). Let the other errors propogate up to the function. You can handle them there and decide if processing should continue or stop.

    hth,
    pr
    ____________________
    Pete

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