CREATE OR REPLACE TRIGGER TR_IC_PROJECT_STO_INS
AFTER INSERT ON IC_PROJECT_STO FOR EACH ROW
DECLARE v_bmjl VARCHAR2(32);v_fgsbmjl varchar2(32);
BEGIN
if substr(:new.f_org,1,2)='10' then
SELECT f_user_id
INTO v_bmjl
FROM bf_user_role_org
WHERE f_org_id = :new.f_org
AND f_role_id = 'R014';
INSERT INTO ic_jdsprdy_xm
SELECT sys_guid(),
SUBSTR(:new.f_org, 1, 2),
:new.f_org,
'',
f_bh,
v_bmjl,
v_bmjl,
'',
'',
:new.f_project_id,
:new.f_project_status
FROM ic_bx_djlx
WHERE f_bh IN ('1000','1021', '1022', '1023', '1024', '1025', '1026', '1122', '1123', '1124', '1125', '1141','1001','1004','1002','1028','1151','1170','2019','2021','1005','1148');
else
SELECT f_user_id
INTO v_bmjl
FROM bf_user_role_org
WHERE f_org_id = :new.f_org
AND f_role_id = 'R017';
SELECT f_user_id
INTO v_fgsbmjl
FROM bf_user_role_org
WHERE f_org_id = :new.f_org
AND f_role_id = 'R019';
INSERT INTO ic_jdsprdy_xm
SELECT sys_guid(),
SUBSTR(:new.f_org, 1, 2),
:new.f_org,
'',
f_bh,
v_fgsbmjl,
v_bmjl,
'',
'',
:new.f_project_id,
:new.f_project_status
FROM ic_bx_djlx
WHERE f_bh IN ('1000','1021', '1022', '1023', '1024', '1025', '1026', '1122', '1123', '1124', '1125', '1141','1001','1004','1002','1028','1151','1170','2019','2021','1005','1148');
end if;
END;