从
this和
this我猜,ORA-00955没有预定义的命名系统异常.
begin EXECUTE IMMEDIATE 'CREATE SEQUENCE S_TEST START WITH 1 INCREMENT BY 1'; exception when OTHERS then Null; end;
你有两个选择:
原文链接:https://www.f2er.com/oracle/205342.html直接通过编号参考例外:
BEGIN EXECUTE IMMEDIATE 'CREATE SEQUENCE S_TEST START WITH 1 INCREMENT BY 1'; EXCEPTION WHEN OTHERS THEN IF sqlCODE = -955 THEN NULL; -- suppresses ORA-00955 exception ELSE RAISE; END IF; END;
其他选项是使用EXCEPTION_INIT Pragma指令将已知的Oracle错误号绑定到用户定义的异常;
DECLARE name_in_use exception; --declare a user defined exception pragma exception_init( name_in_use,-955 ); --bind the error code to the above BEGIN EXECUTE IMMEDIATE 'CREATE SEQUENCE S_TEST START WITH 1 INCREMENT BY 1'; EXCEPTION when name_in_use then null; --suppress ORA-00955 exception END;
BTW Is there any Syntax to catch errors by just providing the error-codes?
是的,我在第一个例子中证明了这一点
进一步阅读以下变化:
> Oracle Reference Documentation on Handling PL/SQL Exceptions