该线程包含一些有用的技巧/示例代码,这些信息与oracle中PRAGMA的使用中的一些高级概念有关,论坛成员可能会觉得有用。
PRAGMA EXCEPTION_INIT
====================
这用于将用户定义的异常绑定到特定的错误号。
例如:要显示用户定义消息的ORACLE DEFINED NUMBER
---------------------
DECLARE
I EXCEPTION;
PRAGMA EXCEPTION_INIT(I,-00001);
BEGIN
INSERT INTO DEPT VALUES(&DNO,'&DNAME','&LOC');
DBMS_OUTPUT.PUT_LINE('ONE RECORD INSERTED');
EXCEPTION
WHEN I THEN
DBMS_OUTPUT.PUT_LINE('DUPLICATE VALUE');
END;
很少有预定义的数字可用于预定义的例外
========================================
dup_val_on_index,-0001
timeout_on_resource,-0051
invalid_cursor,-1001
not_logged_on,-1012
login_denied,-1017
too_many_rows,-1422
zero_divide,-1476
invalid_number,-1722
storage_error,-6500
程序错误,-6501
值错误-6502
rowtype_mismatch,-6504
cursor_already_open,-6511
access_into_null,-6530
collection_is_null,-6531
subscript_outside_limit,-6532
subscript_beyond_count,-6533
From: https://bytes.com/topic/oracle/insights/663445-using-pragma-ii