CREATE OR REPLACE TRIGGER mwb_trigger
before
–AFTER

INSERT

on –理解为在的意思

jw_cj_xscjb –表名

for each ROW
DECLARE

V_COUNT NUMBER(10);
Pragma autonomous_transaction;
begin
SELECT COUNT(*) INTO V_COUNT FROM JW_TAB_XSGPA WHERE xh=:NEW.xh;
IF V_COUNT = 0 THEN
INSERT INTO JW_TAB_XSGPA (XH,GPA,NJ,DQSJ,XNXQ)
select xh, JW_FCJ_PJGPA_ONE(xj_xsxxb.xh ,\’-1-1\’,\’-1-1\’) gpa,nj,SYSDATE dqsj,(SELECT xn||\’-\’||xq from dm_xnxqb WHERE sfdqxq=\’1\’) xnxq from xj_xsxxb WHERE xydm NOT IN (\’41\’,\’44\’,\’45\’,\’18\’) AND xh= :NEW.xh;
ELSE
UPDATE JW_TAB_XSGPA SET GPA=(SELECT JW_FCJ_PJGPA_ONE(:NEW.xh ,\’-1-1\’,\’-1-1\’) from DUAL),NJ=:NEW.NJ,DQSJ=SYSDATE,XNXQ=(SELECT xn||\’-\’||xq from dm_xnxqb WHERE sfdqxq=\’1\’) WHERE XH=:NEW.XH;
END IF;
COMMIT;
END;

版权声明:本文为supermwb原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/supermwb/p/12960482.html