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.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.|||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?|||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?
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment