For table structure follows my another blog for oracle trigger example.
Example
CREATE OR REPLACE PROCEDURE EXCEPTION_TEST(test in VARCHAR2) AS
EMP_NAME VARCHAR2(200);
BEGIN
SELECT NAME INTO EMP_NAME FROM TBL_EMPLOYEE;
EXCEPTION
WHEN TOO_MANY_ROWS THEN
BEGIN
SELECT NAME INTO EMP_NAME FROM TBL_EMPLOYEE WHERE ID=1;
EXCEPTION
WHEN OTHERS THEN
EMP_NAME := 'NOT FOUND';
END;
WHEN OTHERS THEN
EMP_NAME := 'NOT FOUND';
END EXCEPTION_TEST;
- TOO_MANY_ROWS: When your select statement return multiple rows and that situation need to handle then you can use the TOO_MANY_ROWS exception.
- OTHERS : Others is a generic exception which will occur at bottom.
Example
CREATE OR REPLACE PROCEDURE EXCEPTION_TEST(test in VARCHAR2) AS
EMP_NAME VARCHAR2(200);
BEGIN
SELECT NAME INTO EMP_NAME FROM TBL_EMPLOYEE;
EXCEPTION
WHEN TOO_MANY_ROWS THEN
BEGIN
SELECT NAME INTO EMP_NAME FROM TBL_EMPLOYEE WHERE ID=1;
EXCEPTION
WHEN OTHERS THEN
EMP_NAME := 'NOT FOUND';
END;
WHEN OTHERS THEN
EMP_NAME := 'NOT FOUND';
END EXCEPTION_TEST;
No comments:
Post a Comment