|
Here is an example of a procedure that uses a Named
System Exception:
|
|
CREATE OR REPLACE PROCEDURE add_new_supplier
|
|
(supplier_id_in IN NUMBER, supplier_name_in IN
VARCHAR2)
|
|
INSERT INTO suppliers (supplier_id, supplier_name )
|
|
VALUES ( supplier_id_in, supplier_name_in );
|
|
WHEN DUP_VAL_ON_INDEX THEN
|
|
raise_application_error (-20001,'You have tried to
insert a duplicate supplier_id.');
|
|
raise_application_error (-20002,'An error has occurred
inserting a supplier.');
|
|
In this example, we are trapping the Named System
Exception called
|
|
. We are also using the WHEN OTHERS clause to trap all
|
|
remaining exceptions.
Download Hear
|
|
No comments:
Post a Comment