Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2003
    Posts
    5

    Unanswered: row exceptions in pl/sql

    How do i go about this? Is the RAISE a call to the myexception function, when there is an error? Here's what i think. I was wondering if someone could please tell me if my possible solution is right or not. Thank you.

    (my possible solution)
    John Doe, 111222333
    David Wood, 333222111
    Mary Jones, 222222222
    Bruce Smith, 000000000




    Drop table mytable;
    Create table mytable (name varchar2(20), ssn char(9));

    Declare
    fun NUMBER;
    myexception EXCEPTION;
    begin
    begin
    begin
    insert into mytable values('John Doe', '111222333');
    RAISE myexception;
    end;

    insert into mytable values('David Wood', '333222111');
    COMMIT;
    fun := 5/0;

    begin
    insert into mytable values('Mary Jones', '222222222');
    RAISE myexception;
    end;
    EXCEPTION
    WHEN others THEN
    insert into mytable values('Larry Young', '999999999');
    end;

    insert into mytable values('Bruce Smith', '000000000');
    EXCEPTION
    WHEN myexception THEN
    insert into mytable values('Andrew Lee', '888888888');
    end;
    /

    Give the rows in table mytable after the execution of the above anonymous PL/SQL block.

  2. #2
    Join Date
    Aug 2001
    Posts
    66

    Re: row exceptions in pl/sql

    Your solution doesn't appear to be correct, but you only have to run it to figure that out - right?

    When an exception is raised (with RAISE command or other), control passes to the exception handler in the current block (BEGIN .. END). If there is no exception handler in the current block, control is passed to the exception handler of the parent or calling block and so on. If an exception reaches the outer-most block and is not handled by its exception section, PL/SQL terminates with error and an implicit ROLLBACK is performed.
    Padderz
    SYSOP, Quest Software / RevealNet Labs PL/SQL Pipeline

  3. #3
    Join Date
    Aug 2001
    Posts
    66

    Re: row exceptions

    Sorry, not right either. You got John Doe right - but what will happen when the exception is raised right afterwards?

    INSERT INTO mytable
    VALUES ('John Doe', '111222333');

    RAISE myexception; <<-- What happens now?
    Padderz
    SYSOP, Quest Software / RevealNet Labs PL/SQL Pipeline

  4. #4
    Join Date
    Jul 2003
    Posts
    5

    Re: row exceptions

    Does Andrew Lee get printed at all?


    Originally posted by padderz
    Sorry, not right either. You got John Doe right - but what will happen when the exception is raised right afterwards?

    INSERT INTO mytable
    VALUES ('John Doe', '111222333');

    RAISE myexception; <<-- What happens now?

Posting Permissions

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