Oracle触发器行为

时间:2017-01-06 09:30:15

标签: oracle plsql

我遇到下一个问题: 当我在表FORMS中创建新记录时,下一个触发器开始:

CREATE OR REPLACE TRIGGER "REA"."AUTOCREATE_TRIGGER" BEFORE
INSERT ON REA.FORMS
FOR each ROW
 WHEN (NEW.LIST_OF_FORMS_ID=59 OR NEW.LIST_OF_FORMS_ID=60) BEGIN
  IF :NEW.LIST_OF_FORMS_ID=59
      THEN   AUTOCREATE.AUTOCREATE_PR340_FR73_S1_T1(:NEW.POWER_FACILITIES_VID, :NEW.ID);
END

此触发器调用过程,用于创建子文档并将其添加到表PR340_FR73_S1_T1中。所有那些通过FORMS_ID连接的子文档与表FORMS中的相应ID值。

    PROCEDURE AUTOCREATE_PR340_FR73_S1_T1(
    POWERFACILITIES NUMBER,
    FORMSID NUMBER) AS
    BEGIN
FOR ROW IN (SELECT VID FROM poe_steam_turbines 
            WHERE POWER_FACILITIES_VID = POWERFACILITIES
            AND IS_ACTUAL = 1) LOOP
INSERT INTO PR340_FR73_S1_T1 (
        HAS_PROLONGATION ----ПРОДЛЕНИЕ
       ,HAS_REMARKING ---ПЕРЕМАРКИРОВКА
       ,HAS_REPLACEMENT --ЗАМЕНА
       ,HAS_REMOVAL --ВЫВОД
       ,POE_STEAM_TURBINES_VID
       ,FORMS_ID
       ) VALUES (
         0
        ,0
        ,0
        ,0
        ,ROW.VID
        ,FORMSID
    );
    END LOOP;
END AUTOCREATE_PR340_FR73_S1_T1;

当PR340_FR73_S1_T1表中的记录插入时,下一个触发器开始。

    CREATE OR REPLACE TRIGGER "PR340_FR73_S1_T1_EVENT" BEFORE INSERT ON PR340_FR73_S1_T1
FOR EACH ROW
DECLARE
 period NUMBER;
 BEGIN
SELECT PERIOD_ID INTO period FROM FORMS WHERE Id = :NEW.FORMS_ID; -- в этом запросе происходит ошибка из за :NEW.FORMS_ID

  --period:=2016;

   IF :NEW.HAS_REMOVAL = 0
   THEN 
        FILL_EVENT.FILL_REMOVAL_ATR(:NEW.POE_STEAM_TURBINES_VID, period,
        :NEW.STOP_ID, :NEW.REMOVAL_LAST_YEAR);
   END IF;  
END;

如果我定义具有严格值的PERIOD,例如' 2016',代码可以完美运行。但是,当我试图从当前新的FORMS记录中获得PERIOD时 - 出现错误。

0 个答案:

没有答案