This thread contains some useful tips/sample codes regarding some of advance concepts in Use of PRAGMA in oracle, that the forum members may find useful.
PRAGMA EXCEPTION_INIT
=============== =====
This is used to bind a user defined exception to a particular error number.
For example: To display USER DEFINED MESSAGE FOR ORACLE DEFINED NUMBER
---------------------
[CODE=oracle]
DECLARE
I EXCEPTION;
PRAGMA EXCEPTION_INIT( I,-00001);
BEGIN
INSERT INTO DEPT VALUES(&DNO,'&D NAME','&LOC');
DBMS_OUTPUT.PUT _LINE('ONE RECORD INSERTED');
EXCEPTION
WHEN I THEN
DBMS_OUTPUT.PUT _LINE('DUPLICAT E VALUE');
END;
[/CODE]
Few more predefined number for predefined exception
=============== =============== ==========
dup_val_on_inde x, -0001
timeout_on_reso urce, -0051
invalid_cursor, -1001
not_logged_on, -1012
login_denied, -1017
too_many_rows, -1422
zero_divide, -1476
invalid_number, -1722
storage_error, -6500
program_error, -6501
value_error, -6502
rowtype_mismatc h, -6504
cursor_already_ open, -6511
access_into_nul l, -6530
collection_is_n ull , -6531
subscript_outsi de_limit, -6532
subscript_beyon d_count , -6533
PRAGMA EXCEPTION_INIT
=============== =====
This is used to bind a user defined exception to a particular error number.
For example: To display USER DEFINED MESSAGE FOR ORACLE DEFINED NUMBER
---------------------
[CODE=oracle]
DECLARE
I EXCEPTION;
PRAGMA EXCEPTION_INIT( I,-00001);
BEGIN
INSERT INTO DEPT VALUES(&DNO,'&D NAME','&LOC');
DBMS_OUTPUT.PUT _LINE('ONE RECORD INSERTED');
EXCEPTION
WHEN I THEN
DBMS_OUTPUT.PUT _LINE('DUPLICAT E VALUE');
END;
[/CODE]
Few more predefined number for predefined exception
=============== =============== ==========
dup_val_on_inde x, -0001
timeout_on_reso urce, -0051
invalid_cursor, -1001
not_logged_on, -1012
login_denied, -1017
too_many_rows, -1422
zero_divide, -1476
invalid_number, -1722
storage_error, -6500
program_error, -6501
value_error, -6502
rowtype_mismatc h, -6504
cursor_already_ open, -6511
access_into_nul l, -6530
collection_is_n ull , -6531
subscript_outsi de_limit, -6532
subscript_beyon d_count , -6533
Comment