Managing Multiple Errors With a Single Exception Handler
DECLARE
emp_column VARCHAR2(30) := 'last_name';
table_name VARCHAR2(30) := 'emp';
temp_var VARCHAR2(30);
BEGIN
temp_var := emp_column;
SELECT column_name
INTO temp_var
FROM user_tab_cols
WHERE table_name = 'EMPLOYEES'
AND column_name = Upper(emp_column);
-- processing here
temp_var := table_name;
SELECT object_name
INTO temp_var
FROM user_objects
WHERE object_name = Upper(table_name)
AND object_type = 'TABLE';
-- processing here
EXCEPTION
WHEN no_data_found THEN -- catches all 'no data found' errors
dbms_output.Put_line('No Data found for SELECT on '
||temp_var);
END;
/
OUTPUT:-
No Data found for SELECT on emp
PL/SQL procedure successfully completed.
0 comments:
Post a Comment