DM7触发器出现编译错误,无法解决
【DM版本】:DM7
【操作系统】:WIN11
【CPU】:I5-12500H
【问题描述】:改了好几次,始终没发现语法错误,不知道为什么编译不了。代码如下:
create or replace trigger CHENYZ.TRG_PROJECT_STATUS
before insert or update on CHENYZ.PROJECT_STATUS
for each row
declare
unstart exception for -50001, '未开始,开始和结束时间应为空';
working exception for -50002, '进行中,开始时间不能为空,结束时间应为空';
complt exception for -50003, '已完成,开始和结束时间不能为空';
begin
case :new."STATUS"
when '未开始' then
if :new."COMPLETIONDATE" is not NULL or :new."STARTDATE" is not NULL then
raise unstart;
end if;
when '进行中' then
if :new."STARTDATE" is NULL or :new."COMPLETIONDATE" is not NULL then
raise working;
end if;
when '已完成' then
if :new."STARTDATE" is NULL or :new."COMPLETIONDATE" is NULL then
raise complt;
end if;
end case;
end;
还有另外一个代码同样报错:
create or replace trigger CHENYZ.TRG_PROJECT_STATUS
before insert or update on CHENYZ.PROJECT_STATUS
for each row
declare
unstart exception for -30001;--, '未开始,开始和结束时间应为空';
working exception for -30002;--, '进行中,开始时间不能为空,结束时间应为空';
complt exception for -30003;--, '已完成,开始和结束时间不能为空';
begin
if :new."STATUS" = '未开始' then
if (:new."COMPLETIONDATE" is not NULL or :new."STARTDATE" is not NULL) then
raise unstart;
end if;
elsif :new."STATUS" = '进行中' then
if (:new."STARTDATE" is NULL or :new."COMPLETIONDATE" is not NULL) then
raise working;
end if;
else
if (:new."STARTDATE" is NULL or :new."COMPLETIONDATE" is NULL) then
raise complt;
end if;
end if;
end;
错误截图如下:
在 DMSQL 程序的声明部分使用该语法声明一个异常变量。其中,FOR 子句用来为异常
变量绑定错误号(SQLCODE 值)及错误描述。<错误号>必须是**-20000 到-30000** 间的负数
值,<错误描述>则为字符串类型。如果未显式指定错误号,则系统在运行中在-10001 到-
15000区间中顺序为其绑定错误值。