我正在为我的数据库创建一个触发器。在我的触发器代码中,我应该使用哪个number参数:
set serveroutput on
create or replace trigger iss_bk
after insert on Issue
for each row
declare
p integer;
q integer;
begin
select Available_copy
into p
from book
where Book.ISBN = :NEW.book_id;
q := p - :NEW.quantity;
if q < 0 then
RAISE_APPLICATION_ERROR(-1722,' Exceeded available quantity of book .');
else
update Book set
Available_copy = q
where Book.ISBN = :NEW.book_id;
end if;
end;
/当Q<0输入时,错误是:
ORA-21000: error number argument to raise_application_error of -1722 is out of range
ORA-06512: at "R1507090.ISS_BK", line 9发布于 2018-06-29 15:17:48
根据文档的说法(如果需要的话,可以选择另一个版本,但我不认为有那么多)。“处理PL/SQL错误”说:
raise_application_error(error_number,message,{真假}); 哪里
这意味着你应该使用,例如,
RAISE_APPLICATION_ERROR(-20001, 'Exceeded available quantity of book.');可以重用相同的ERROR_NUMBER值,也就是说,如果需要,您自己的所有错误消息都可以共享相同的"-20001“代码。
https://stackoverflow.com/questions/51032965
复制相似问题