首页 > 解决方案 > 触发测试,无效语句

问题描述

已解决在触发器中“或更新”之前忘记“插入”。

 create or replace trigger biufer_bankkund
before insert or update on bankkund
for each row
begin
if NOT LENGTH (:NEW.PASSWD) = 6 then
raise_application_error
(-20001,'För låg ny lön!');
end if;
end;

所以我创建了一个触发器,它应该维护只包含 6 个字母的密码。

我的猜测是触发器不正确,就像我从 bankkund 做的 Select* 一样,其中有一个密码只有 3 个字母的数据。

create or replace trigger biufer_bankkund
before update on bankkund
for each row
begin
if NOT LENGTH (:NEW.PASSWD) = 6 then
raise_application_error
(-20001,'För låg ny lön!');
end if;
end;

然后是带有参数 PNR、FNAMN、ENAMN、PASSWD 的程序。

create or replace procedure do_bankkund(
p_pnr in bankkund.pnr%type,
p_fnamn in bankkund.fnamn%type,
p_enamn in bankkund.enamn%type,
p_passwd in bankkund.passwd%type)
is
begin
insert into bankkund(pnr,fnamn,enamn,passwd)
values(p_pnr,p_fnamn,p_enamn,p_passwd);
end;
/

一切顺利,但确实触发了测试,以测试在 PASSWD 中输入多于/少于 6 个字母是否会返回一个带有“错误文本”的错误)。但我只得到“无效声明”

任何人?谢谢

Triggertest  =   EXEC do_bankkund('691124-4478','Leena','Kvist','qwe');

标签: sqloracle

解决方案


推荐阅读