insert into t_tbo_plinfo_e(fid)
select fid from t_tbo_plinfo g  where not exists  (select e.fid from t_tbo_plinfo_e e where  e.fid = g.fid);

update t_tbo_plinfo_e e set  ftradebizdate = (select t.fbizdate from t_tm_trade t join t_tbo_plinfo p on t.fid = p.ftradebillid where p.fid = e.fid )
where exists (select p.fid from t_tbo_plinfo p where p.fid = e.fid and p.fsrcbizbillid=0);

update t_tbo_plinfo_e e set  ftradebizdate = (select fbizdate from t_tm_businessbill b join t_tbo_plinfo p on b.fid = p.fsrcbizbillid where p.fid = e.fid )
where exists (select p.fid from t_tbo_plinfo p where p.fid = e.fid and p.fsrcbizbillid>0);

update t_tbo_plinfo_e e set fforexswaptype = 'spot'
where exists
	(
		select t.fid from t_tbo_plinfo p
		join  t_tm_trade t on t.fid = p.ftradebillid
		join t_tm_trade_f f on f.fid = p.ftradebillid
		where p.fid = e.fid and ((p.fswapdir='isnear' and f.fswaptype = 'SpotToFwd') or f.fswaptype = 'SpotToSpot')
	);

update t_tbo_plinfo_e e set fforexswaptype = 'forward'
where exists
	(
		select t.fid from t_tbo_plinfo p
		join  t_tm_trade t on t.fid = p.ftradebillid
		join t_tm_trade_f f on f.fid = p.ftradebillid
		where p.fid = e.fid and ((p.fswapdir='isfar' and f.fswaptype = 'SpotToFwd') or f.fswaptype = 'FwdToFwd')
	);