sql - 触发测试,无效语句
问题描述
已解决在触发器中“或更新”之前忘记“插入”。
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');
解决方案
推荐阅读
- regex - 用于客户端验证的黑名单、不区分大小写的正则表达式
- java - 在输出之间添加/删除字符
- python - 如何在python中的行首和行尾添加一个字符
- aws-step-functions - 报告 AWS Step Function 中的活动执行时间
- c++ - 英特尔在故意重叠的内存区域上存储指令
- django - Django 构建用户对用户的消息传递系统
- reactjs - 测试 redux 操作时调度不是函数
- excel - 试图在范围内找到值并获得它的行。变量未设置错误?
- jquery - 阻止子锚标记指向其他页面
- mongodb - 需要使用 mongoDB 聚合在数组中标记付费分期付款