--built_in_exceptions.sql SET SERVEROUTPUT ON; DECLARE v_Cust_no NUMBER := &sv_student_id; v_enrolled VARCHAR2(3) := 'NO'; BEGIN SELECT 'YES' INTO v_enrolled FROM bookings WHERE Cust_no = v_Cust_no; EXCEPTION WHEN NO_DATA_FOUND THEN DBMS_OUTPUT.PUT_LINE('This customer rented from us'); WHEN TOO_MANY_ROWS THEN DBMS_OUTPUT.PUT_LINE ('This customer rented from us more than once!'); END; --****************************************************** --EXCEPTION SCOPE BEGIN -- outer block DECLARE -- inner block v_test_var CHAR(3); --:= 'ABCDE'; BEGIN v_test_var:= 'ABCDE'; DBMS_OUTPUT.PUT_LINE('This is a test'); EXCEPTION WHEN VALUE_ERROR OR INVALID_NUMBER THEN DBMS_OUTPUT.PUT_LINE ('An error has occurred in the inner block'); END; -- end of inner block DBMS_OUTPUT.PUT_LINE('This is an outer block'); EXCEPTION WHEN VALUE_ERROR OR INVALID_NUMBER THEN DBMS_OUTPUT.PUT_LINE ('An error has occurred in the program'); END; --******************************************************* --reraising_exception1.sql SET SERVEROUTPUT ON; DECLARE e_exception EXCEPTION; BEGIN BEGIN RAISE e_exception; EXCEPTION WHEN e_exception THEN RAISE; END; EXCEPTION WHEN e_exception THEN DBMS_OUTPUT.PUT_LINE('An error has occurred'); END; /