2011-04-19 48 views
1

trigger error:=ORA-04079: invalid trigger specification觸發錯誤:= 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; 

回答

6

你應該在聲明的變量在使用前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