If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > row exceptions in pl/sql

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-07-03, 19:17
zinny03 zinny03 is offline
Registered User
 
Join Date: Jul 2003
Posts: 5
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.
Reply With Quote
  #2 (permalink)  
Old 07-08-03, 04:21
padderz padderz is offline
Registered User
 
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
Reply With Quote
  #3 (permalink)  
Old 07-09-03, 04:06
padderz padderz is offline
Registered User
 
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
Reply With Quote
  #4 (permalink)  
Old 07-09-03, 11:44
zinny03 zinny03 is offline
Registered User
 
Join Date: Jul 2003
Posts: 5
Re: row exceptions

Does Andrew Lee get printed at all?


Quote:
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?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On