我正在编写下面的触发器,我在尝试插入此字段FIELD_OLD_VALUE,FIELD_NEW_VALUE
的值时收到错误。我必须根据Select查询插入此字段的值,但我得到的错误为SQL Statement Ignored ORA-000936 missing expression in Oracle trigger
。我不想在字段FIELD_OLD_VALUE,FIELD_NEW_VALUE
中使用变量,因为我在此问题中仅为ENV_ID
字段编写了insert语句,并且我在此触发器中添加了许多其他字段。因此很难对每个领域进行变量和维护。
create or replace TRIGGER RATOR_MONITORING_CONFIGURATION."TRG_TRK_KPI_DEFINITION" AFTER UPDATE ON RATOR_MONITORING_CONFIGURATION.KPI_DEFINITION
FOR EACH ROW
BEGIN
--NEU
IF NOT :old.ENV_ID=:new.ENV_ID THEN
INSERT INTO RATOR_MONITORING_CONFIGURATION.FIELD_TRACKING (FIELD_TRACKING_ID,TABLE_NAME,TABLE_ID, FIELD_NAME,FIELD_OLD_VALUE,FIELD_NEW_VALUE,USER_ID, TIMESTAMP)
VALUES (FIELD_TRACKING_SEQ.NEXTVAL,'KPI_DEFINITION',:new.KPI_DEF_ID,'Environment',to_char(Select NAME FROM ENVIRONMENT WHERE ENV_ID =:old.ENV_ID),to_char(Select NAME FROM ENVIRONMENT WHERE ENV_ID =:new.ENV_ID),:new.LAST_UPDATED_BY,:new.LAST_UPDATED_DATE );
END IF;
END;
答案 0 :(得分:2)
如果您使用子查询作为参数,则需要将它们包含在额外的括号中:
to_char((Select NAME FROM ENVIRONMENT WHERE ENV_ID =:old.ENV_ID))