另一个 04079:无效的触发器规范
Posted
技术标签:
【中文标题】另一个 04079:无效的触发器规范【英文标题】:another 04079: invalid trigger specification 【发布时间】:2014-04-22 14:43:48 【问题描述】:触发器创建的语法对我来说看起来是正确的,但我很难找到引发此错误的原因。 此触发器的目的是在源表添加条目后填充两个不同的表。任务表添加了行,然后 CADP_IMPORT 和 CADP_EXPORT 表仅获取从任务表中的相应列填充的非空列。 RAVE 表也是如此。 varcdesc 变量位于两个连接之外的表上。这就是定义要复制到哪组外部表的内容。
CREATE OR REPLACE TRIGGER UPDATEEXTERNAL
AFTER UPDATE
ON TASKS
REFERENCE new as new old as old
FOR EACH ROW
WHEN (:new.status like 'CODE VERBATIM #%')
DECLARE
vareid varchar2(50);
varcdesc varchar2(50);
BEGIN
vareid := externalid;
select c.description into varcdesc from configurations c, jobs j, tasks t
where t.jobid = j.id
and j.configurationid = c.id;
IF varcdesc = 'CADP AE and MH Convention'
OR varcdesc = 'CADP CM Convention' THEN
INSERT ALL
INTO IATINTEGRATION.CADP_IMPORT
(EXTERNALID,TERM,FROMSYS,PROT,TYPE,DATASET,VARNAME,BATCH,PNO)
VALUES
(vareid,t.verbatim,t.REF1,t.REF2,t.REF3,t.REF4,t.REF5,t.REF6,t.REF7)
INTO IATEINTEGRATION.CADP_EXPORT
(EXTERNALID,VERBATIM,FROMSYS,PROT,TYPE,DATASET,VARNAME,BATCH,PNO)
VALUES
(vareid,t.verbatim,t.REF1,t.REF2,t.REF3,t.REF4,t.REF5,t.REF6,t.REF7);
ELSE IF varcdesc = 'RAVE AE and MH Convention'
OR varcdesc = 'RAVE CM Convention' THEN
INSERT ALL
INTO IATINTEGRATION.RAVE_IMPORT
(EXTERNALID,VERBATIM_TERM,STUDY_ID)
VALUES
(vareid,t.verbatim,t.REF1)
INTO IATINTEGRATION.RAVE_EXPORT
(EXTERNALID,VERBATIM_TERM,STUDY_ID)
VALUES
(vareid,t.verbatim,t.REF1);
END IF;
END;
【问题讨论】:
为什么在插入中引用t.
列?这仅对INSERT ... SELECT
有效,对INSERT ... VALUES
无效。
【参考方案1】:
试试这个:
CREATE OR REPLACE TRIGGER UPDATEEXTERNAL
AFTER UPDATE
ON TASKS
REFERENCE new as t old as old
FOR EACH ROW
WHEN (:new.status like 'CODE VERBATIM #%')
DECLARE
vareid varchar2(50);
varcdesc varchar2(50);
BEGIN
vareid := externalid;
select c.description into varcdesc from configurations c, jobs j, tasks tsk
where tsk.jobid = j.id
and j.configurationid = c.id;
IF varcdesc = 'CADP AE and MH Convention'
OR varcdesc = 'CADP CM Convention' THEN
INSERT ALL
INTO IATINTEGRATION.CADP_IMPORT
(EXTERNALID,TERM,FROMSYS,PROT,TYPE,DATASET,VARNAME,BATCH,PNO)
VALUES
(vareid,t.verbatim,t.REF1,t.REF2,t.REF3,t.REF4,t.REF5,t.REF6,t.REF7)
INTO IATEINTEGRATION.CADP_EXPORT
(EXTERNALID,VERBATIM,FROMSYS,PROT,TYPE,DATASET,VARNAME,BATCH,PNO)
VALUES
(vareid,t.verbatim,t.REF1,t.REF2,t.REF3,t.REF4,t.REF5,t.REF6,t.REF7);
ELSE IF varcdesc = 'RAVE AE and MH Convention'
OR varcdesc = 'RAVE CM Convention' THEN
INSERT ALL
INTO IATINTEGRATION.RAVE_IMPORT
(EXTERNALID,VERBATIM_TERM,STUDY_ID)
VALUES
(vareid,t.verbatim,t.REF1)
INTO IATINTEGRATION.RAVE_EXPORT
(EXTERNALID,VERBATIM_TERM,STUDY_ID)
VALUES
(vareid,t.verbatim,t.REF1);
END IF;
END;
【讨论】:
以上是关于另一个 04079:无效的触发器规范的主要内容,如果未能解决你的问题,请参考以下文章