--插入数据
INSERT INTO MF_ARP(ARP_ID,OPN_ID,BIL_NO,BIL_DD,CUS_NO,AMT,CUR_ID,EXC_RTO,amtn,amtn_net,ARP_NO)
SELECT '1','2',PS_NO,PS_DD,CUS_NO,AMT,CUR_ID,EXC_RTO,AMt*exc_rto, AMt*exc_rto,ARP_NO
FROM MF_PSS where ps_id='SA' and ps_no not in(select bil_no from mf_arp)
GO
--单据日期
GO
UPDATE A SET a.PAY_DD=b.PAY_DD from mf_arp a,mf_pss b where a.bil_no=b.ps_no and b.ps_id='SA'
GO
--部门同步
UPDATE A SET a.dep=b.DEP from mf_arp a,mf_pss b where a.bil_no=b.ps_no and b.ps_id='SA'
GO
--金额同步
UPDATE A SET a.AMTN=b.AMTN_NET_TOT from mf_arp a,mf_pss b where a.bil_no=b.ps_no and b.ps_id='SA'
GO
--税额同步
UPDATE a
SET a.tax = (
SELECT SUM(b.tax)
FROM tf_pss b
WHERE b.ps_no = a.bil_no AND b.ps_id = 'SA'
)
FROM mf_arp a
WHERE EXISTS (
SELECT 1
FROM tf_pss b
WHERE b.ps_no = a.bil_no AND b.ps_id = 'SA'
);
GO
--立账ID同步
UPDATE A SET a.BIL_ID=b.PS_ID from mf_arp a,tf_pss b where a.bil_no=b.ps_no and b.ps_id='SA'
GO
--立账日期同步
UPDATE A SET a.lz_dd=b.ps_dd from mf_arp a,mf_pss b where a.bil_no=b.ps_no and b.ps_id='SA'
GO
--制单人同步
UPDATE A SET a.usr_no=b.USR from mf_arp a,mf_pss b where a.bil_no=b.ps_no and b.ps_id='SA'
GO
--备注同步
UPDATE A SET a.PAY_REM=b.PAY_REM from mf_arp a,mf_pss b where a.bil_no=b.ps_no and b.ps_id='SA'
--金额同步
UPDATE mf_arp set AMTN_NET=AMTN-TAX WHERE BIL_ID='SA'
GO
最后修改:2025 年 01 月 10 日
© 允许规范转载