To handle error condition that dont have predefined name, you must use OTHERS handler or Pragma EXECEPTION_INIT. A pragma is compiler directive that is process at compile time, not run time
In PL/SQL pragma EXCEPTION_INIT is declared in DECLARE section and it associate with oracle error number
SET SERVEROUTPUT ON
DECLARE
invalid_depto EXCEPTION;
--check constraint violated
PRAGMA EXCEPTION_INIT (invalid_depto, -2290);
BEGIN
INSERT INTO EMP (empno, ename,salary,deptno)
VALUES (90,''Justin',2000,'X');
COMMIT;
EXCEPTION
WHEN invalid_depto THEN
DBMS_OUTPUT.PUT_LINE('Dept No Check constraint violated');
END;
Subscribe to:
Post Comments (Atom)
External Table
Oracle External Table External tables are defined as tables that do not resides in the database allows you to access data that is stor...
-
Oracle PL/SQL block accepts user input information with the help of substitution variable. Substitute variable can not be used to output va...
-
Table clustering is an optional technique of storing data. In table clustering, rows from one or more tables those are associated with ea...
-
DECLARE TYPE emp_ref_cursor IS REF CURSOR; TYPE empno_tab IS TABLE OF NUMBER; TYPE ename_tab IS TABLE OF VARCHAR2(50); v_emp_...
No comments:
Post a Comment