我有一个表bugs_metadata 创建表bugs_metadata(REPORT_NAME varchar2(10),WHERE_CLAUSE varchar2(100)); 插入bugs_metadata('test','29603754,29605708,29649865'); 上表中的WHERE_CLAUSE列更新时,以下触发器中出现“正在变异,触发器/函数可能看不到它”错误:
create or replace TRIGGER "c_b_c_b_update" AFTER
UPDATE ON bugs_metadata
FOR EACH ROW
BEGIN
CASE
WHEN UPDATING('WHERE_CLAUSE') THEN
IF :NEW.WHERE_CLAUSE is not null THEN
insert into bug_data(BUG_NUMBER,SUBJECT)
select rptno,SUBJECT
from rpthead
where rptno in (select regexp_substr(:NEW.WHERE_CLAUSE,'[^,]+',1,level) WHERE_CLAUSE
from bugs_metadata t2
connect by regexp_substr(:NEW.WHERE_CLAUSE,'[^,]+',1,level) is not null )
and rptno not in(select bug_number from bug_data);
END IF;
END CASE;
END;
请让我知道这是怎么回事?
答案 0 :(得分:1)
DUAL
应该代替bugs_metadata
。这样做没有问题,因为您只是将一列拆分成几行,因此无需使用实际表,因为:new.where_clause
中已经存在该值。
参见--> right here -->
行,它标记了该点。
create or replace trigger c_b_c_b_update
after update on bugs_metadata
for each row
begin
case
when updating('WHERE_CLAUSE') then
if :new.where_clause is not null then
insert into bug_data(bug_number, subject)
select rptno, subject
from rpthead
where rptno in (select regexp_substr(:new.where_clause, '[^,]+', 1, level)
--> right here --> from dual
connect by regexp_substr(:new.where_clause, '[^,]+', 1, level) is not null
)
and rptno not in (select bug_number
from bug_data
);
end if;
end case;
end;