oracle 触发器错误:=ORA-04079: 无效的触发器规范
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5712805/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 23:23:47 来源:igfitidea点击:
trigger error:=ORA-04079: invalid trigger specification
提问by user714698
trigger error:=ORA-04079: invalid trigger specification
触发器错误:=ORA-04079: 无效的触发器规范
the code causing that error is below:
导致该错误的代码如下:
CREATE OR REPLACE TRIGGER TRGBILLINGADDRESS
AFTER INSERT OR DELETE OR UPDATE ON TBLMACCOUNTADDRESS
add1 wom.tbltaddress.address1%TYPE;
add2 wom.tbltaddress.address2%TYPE;
cityid wom.tbltaddress.city_id%TYPE;
stateid wom.tbltaddress.state_id%TYPE;
pincd wom.tbltaddress.pincode%TYPE;
BEGIN
SELECT address1,address2,city_id,state_id,pincode
INTO add1,add2,cityid,stateid,pincd FROM wom.tbltaddress ta WHERE ta.ID IN (
SELECT vbac.billing_address_id
FROM wom.vw_billaddresschange vbac, wom.tbltaddress ita
WHERE vbac.billing_address_id = ita.ID
AND vbac.lcid = parlcid);
IF add1 = :NEW.address1 AND add2 = :NEW.address2 AND cityid = :NEW.cityid AND stateid = :NEW.stateid AND pincode = :NEW.zip THEN
dbms_output.put_line('Address Already Exist in tbltaddress table');
ELSE
UPDATE wom.tbltaddress ta
SET ta.address1 = :NEW.address1,
ta.address2 = :NEW.address2,
ta.city_id = :NEW.cityid,
ta.country_id = 'CTR0001',
ta.state_id = :NEW.stateid,
ta.pincode = :NEW.zip
WHERE ta.ID IN (
SELECT vbac.billing_address_id
FROM wom.vw_billaddresschange vbac, wom.tbltaddress ita
WHERE vbac.billing_address_id = ita.ID
AND vbac.lcid = parlcid);
END IF;
END;
回答by Benoit
You should use DECLARE
before declaring your variables.
您应该DECLARE
在声明变量之前使用。
CREATE OR REPLACE TRIGGER TRGBILLINGADDRESS
AFTER INSERT OR DELETE OR UPDATE ON TBLMACCOUNTADDRESS
DECLARE
add1 wom.tbltaddress.address1%TYPE;
add2 wom.tbltaddress.address2%TYPE;
cityid wom.tbltaddress.city_id%TYPE;
stateid wom.tbltaddress.state_id%TYPE;
pincd wom.tbltaddress.pincode%TYPE;
BEGIN