ORA-06510:PL/SQL:未处理的用户定义异常 [Oracle]
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27247200/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ORA-06510: PL/SQL: unhandled user-defined exception [Oracle]
提问by Briscoooe
I'm relatively new to Oracle so forgive me for my lack of knowledge. Whenever this trigger is fired I keep getting an error stating that I have an unhandled user-defined exception. Elsewhere in my functions and procedures I have declared and raised my user-defined exactly as this but in this case is doesn't work. I know it's probably something trivial and obvious but as I said I'm fairly new to Oracle so please forgive me.
我对 Oracle 比较陌生,所以请原谅我缺乏知识。每当触发此触发器时,我都会收到一条错误消息,指出我有一个未处理的用户定义异常。在我的函数和过程的其他地方,我已经完全按照这个声明和提升了我的用户定义,但在这种情况下是行不通的。我知道这可能是微不足道的,但正如我所说,我对 Oracle 还很陌生,所以请原谅我。
CREATE OR REPLACE TRIGGER PROGRAMME_BI
BEFORE INSERT ON PROGRAMME
DECLARE
v_run_time programme.run_time%TYPE;
INVALID_DURATION EXCEPTION;
BEGIN
IF v_run_time > 5 THEN
DBMS_OUTPUT.PUT_LINE('Program duration is valid');
COMMIT;
ELSE
RAISE INVALID_DURATION;
END IF;
EXCEPTION
WHEN INVALID_DURATION THEN
RAISE_APPLICATION_ERROR(-20001,'Program duration is not long enough');
ROLLBACK WORK;
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(SQLCODE||SQLERRM);
END;
UPDATEI have updated the line after the exception is raised so it doesn't give me the unhandled user-defined exception error anymore. However it still does not work as intended. Whenever I enter in a program duration greater than 5 I get the following in the DBMS output window.
更新我在引发异常后更新了该行,因此它不再给我未处理的用户定义的异常错误。但是,它仍然无法按预期工作。每当我输入大于 5 的程序持续时间时,我都会在 DBMS 输出窗口中得到以下信息。
-20001ORA-20001: Program duration is not long enough
ORA-06512: at "DT2113A.PROGRAMME_BI", line 13
ORA-04088: error during execution of trigger 'DT2113A.PROGRAMME_BI'
Program not added
回答by psaraj12
you have to assign value to v_run_time Kindly try the below
您必须为 v_run_time 赋值 请尝试以下操作
CREATE OR REPLACE TRIGGER PROGRAMME_BI
BEFORE INSERT ON PROGRAMME
FOR EACH ROW
DECLARE
v_run_time programme.run_time%TYPE:=:new.run_time;
INVALID_DURATION EXCEPTION;
BEGIN
IF v_run_time > 5 THEN
DBMS_OUTPUT.PUT_LINE('Program duration is valid');
COMMIT;
ELSE
RAISE INVALID_DURATION;
END IF;
EXCEPTION
WHEN INVALID_DURATION THEN
RAISE_APPLICATION_ERROR(-20001,'Program duration is not long enough');
ROLLBACK WORK;
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(SQLCODE||SQLERRM);
END;