【发布时间】:2015-01-19 05:30:32
【问题描述】:
我正在尝试为我的数据库表创建一个触发器,以便用户只能输入 6-8 个字符长的邮政编码。但是,即使触发器没有显示任何错误,这似乎也不起作用。
代码如下:
create or replace trigger loc_postcode
before insert or update of postcode
on location
for each row
begin
if ( LENGTH(:new.postcode) > 8) or ( LENGTH(:new.postcode) < 6)
then raise_application_error(0001,
'The postcode must be between 6 and 8 characters long');
end if;
end;
和错误:
ORA-04098:触发器 'C3392387.LOC_ID' 无效并且重新验证失败
【问题讨论】:
-
您的触发器名称为
loc_postcode,但您的错误消息提到了一个名为LOC_ID的触发器 - 该触发器是否也有错误?
标签: database oracle plsql triggers