在sqlserver2000中实现类似oracle的Merge into的方法
?? begin tran t1
??????? declare @existflag int
??????? SELECT @existflag =rcgoobpr_flag FROM ri_rcgoobpr where ri_manageunitcode=#rvManageunitCode# and
??????? rcgoobpr_id=#rcgoobpr_id#
??????? if(@existflag is not null)
??????? begin
??????? update ri_rcgoobpr set
??????? rvrcds_id=#rvrcds_id#,bnds=#bnds#,brnm=#brnm#,infndt=#infndt#,goennmcd=#goennmcd#,lfbnpl=#lfbnpl#,
??????? wtlvbkin=#wtlvbkin#,brar=#brar#,brdm=#brdm#,brinchwd=#brinchwd#,brigwtar=#brigwtar#,rvbrpl=#rvbrpl#,
??????? rvbrin=#rvbrin#,rm=#rm#,usercode=#usercode#,username=#username#,operationdate=getdate()
??????? WHERE rcgoobpr_id=#rcgoobpr_id#
??????? AND ri_manageunitcode=#rvManageunitCode#
??????? end
??????? else
??????? begin
??????? INSERT INTO ri_rcgoobpr
??????? (rcgoobpr_id,rvrcds_id,bnds,brnm,ri_manageunitcode,infndt,goennmcd,lfbnpl,wtlvbkin,brar,brdm,brinchwd,brigwtar,rvbrpl,
??????? rvbrin,rm,usercode,username,operationdate,errorflag,auditingflag,sendflag,flag)
??????? VALUES
?????????? (#rcgoobpr_id#,#rvrcds_id#,#bnds#,#brnm#,#rvManageunitCode#,#infndt#,#goennmcd#,#lfbnpl#,#wtlvbkin#,#brar#,#brdm#,#brinchwd#,
??????? #brigwtar#,#rvbrpl#,#rvbrin#,#rm#,#usercode#,#username#,getdate(),#errorflag#,
??????? #auditingflag#,#sendflag#,#flag#)
????????
??????? end
??????? commit tran t1
??????? <![CDATA[if(@@error>0)]]>
??????? begin
??????? rollback tran t1
??????? end
以上是用sqlserver2000开发的类似于oracle中的merge into 的语句,以上语句是在ibatis中开发的