我有一个触发器,我正尝试使用它来更新它侦听的同一张表。
但是,提交创建或更新后,出现以下错误:
ORA-04091: table [username].ADDRESSES is mutating, trigger/function may not see it ORA-06512: at "[username].ADDRESSES_T1", line 9 ORA-04088: error during execution of trigger '[username].ADDRESSES_T1'
感谢您的帮助!
您正在更新触发器已写入的同一表。您需要这样的东西:
create or replace trigger "ADDRESSES_T1" BEFORE insert or update on "ADDRESSES" for each row begin DECLARE l_lat NUMBER; l_lng NUMBER; l_postcode VARCHAR2(8) := :NEW.POSTCODE; BEGIN brian.POSTCODE_TO_LAT_LNG_GM_API (l_postcode, l_lat, l_lng); :new.location = SDO_GEOMETRY(2001, --SDO_GTYPE 8307, --SDO_SRID SDO_POINT_TYPE(l_lng, --X lng l_lat, --Y lat null), --Z null, --SDO_ELEM_INFO_ARRAY null); END;