【发布时间】:2018-12-02 09:56:19
【问题描述】:
我正在创建一个触发器以将相同的 SEQ.nextval 数字添加到两个字段,如下所示:
SITE_NUM SITE_NUM_COPY Site_Name
346 346 XYZ
347 347 ABC
348 348 DEF
每当通过应用程序添加新行时,我希望通过触发器自动生成 SITE_NUM 和 SITE_NUM_COPY。
这是我整理的:
create or replace trigger SITE_TRIGGER
before insert or update on STRATEGY_SITES for each row
begin
if updating then
if :new.SITE_NUM is null and :new.SITE_NUM_Copy is NULL then
:new.SITE_NUM := :old.SITE_NUM
and :old.SITE_NUM := :new.SITE_NUM_COPY;
end if;
end if;
if inserting then
:new.SITE_NUM := SITENUM_SEQ.nextval
and :new.SITE_NUM_COPY := SITENUM_SEQ.nextval;
end if;
end;
得到以下错误:
错误 (7,31):PLS-00103:在预期以下情况之一时遇到符号“=”:
. ( * @ % & = - + ; at in is mod remaining not rem or != or ~= >= and or like2 like4 likec between || 指示符多集成员子多集
在“=”之前插入符号“*”以继续。
【问题讨论】:
标签: oracle sequence database-trigger