--升级折本位币已实现损益
update T_TBO_PLINFO_ENTRYS set fpllocalamt = fplamt where fplamt <> 0 and (fpllocalamt = 0 or fpllocalamt is null);

--升级无本金交割 记账损益=>0
update t_tbo_plinfo_e e
set fvoucher_pl = 0
where exists (
    select p.fid from t_tbo_plinfo p
    join t_tm_trade_f f on f.fid = p.ftradebillid
    where p.fid = e.fid and f.fdeliveryway = 'non-deliverable' and e.fvoucher_pl<>0
);

--升级无本金交割 记账损益=>0
update t_tbo_plinfo_history h
set fvoucher_pl = 0
where exists (
    select f.fid from t_tm_trade_f f
    where f.fid = h.ftradebillid and f.fdeliveryway = 'non-deliverable' and h.fvoucher_pl<>0
);

--升级合计折本位币已实现损益
update T_TBO_PLINFO p
set fsumpllocalamt = (select sum(fpllocalamt) from T_TBO_PLINFO_ENTRYS e where e.fid = p.fid)
where exists (
	select e.fid from T_TBO_PLINFO_ENTRYS e
    where e.fid = p.fid
)
and (p.fsumpllocalamt = 0 or p.fsumpllocalamt is null);