I have been trying to access the below code
DECLARE
N_DEPTNO DEPT.DEPTNO %TYPE :=&DEPT_NUM;
V_DNAME DEPT.DNAME %TYPE;
NOT_ENOUGH_VALUES EXCEPTION;
PRAGMA
EXCEPTION_INIT(NOT_ENOUGH_VALUES,-06502);
BEGIN
SELECT DNAME,LOC INTO DNAME FROM DEPT
WHERE DEPTNO = N_DEPTNO;
DBMS_OUTPUT.PUT_LINE('Successfully Fetched !!');
EXCEPTION
WHEN NOT_ENOUGH_VALUES THEN
DBMS_OUTPUT.PUT_LINE('No Enough Values ... ');
END;
It is still showing error message after specified it in EXCEPTION block.
Can i handle these type of errors using PRAGMA EXCEPTION_INIT
i.e not providing enough values in the select statement…
If not what type of errors can be handled in System Defined Unnamed Exception
using PRAGMA EXCEPTION_INIT.
Exception handlers can catch runtime errors. They cannot catch compilation errors. The compiler figures out when it is compiling your code that it is syntactically invalid– not enough values are specified in the
INTOclause. So the exception is raised before your code is executed.