您好,请您建议我尝试检查count = 2 当条件满足(DA.matr_ID ='478')或(DA.matr_ID ='40')时 插入表中,但在(DA.matr_ID ='479')这样的任何条件下,它都会插入错误的数据
CREATE OR REPLACE TRIGGER DEVICE_TMP_TR
AFTER INSERT OR UPDATE ON DEVICE_ATTRIBUTES_TMP
REFERENCING OLD AS old NEW AS new
FOR EACH ROW
DECLARE
pragma autonomous_transaction;
V_COUNT NUMBER;
BEGIN
SELECT COUNT(*)
INTO V_COUNT
FROM DEVICE_ATTRIBUTES_TMP DA
WHERE DA.DVS_ID = :new.DVS_ID
AND (DA.matr_ID = '40' or DA.matr_ID = '478');
IF V_COUNT = 2 THEN
INSERT Into APP_DELETED_TMP
(sdmid,appid,devis,des_nr,creation_date,creation_user,ant_id)
VALUES
('121213', '23', '45','63',SYSDATE,'hhdhSH',21);
COMMIT;
ELSE
RETURN;
END IF;
END;