触发错误:=ORA-04079: 无效的触发规范

发布于 2024-11-01 21:47:28 字数 1637 浏览 0 评论 0原文

触发错误:=ORA-04079: 无效 触发规范

导致该错误的代码如下:

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;

trigger error:=ORA-04079: invalid
trigger specification

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;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烟织青萝梦 2024-11-08 21:47:28

在声明变量之前,您应该使用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

You should use DECLARE before declaring your variables.

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文