IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[order_32_1358_wrklink_after]') AND type = 'P')
DROP PROCEDURE [dbo].[order_32_1358_wrklink_after]
GO

-- 生成时间:2018-05-04 09:51:48 by ebs-core  
CREATE  procedure order_32_1358_wrklink_after(
     @cmpid int, 
     @useruid int,
     @bizid int, 
     @ordid bigint, 
     @wrkid int, 
     @jbid bigint, 
     @wsid int, 
     @wsstatus nvarchar(50) 
  ) 
as  
begin  
set nocount on  
declare @nonedate datetime 
set @nonedate = CONVERT(datetime,'1910-1-1')
declare @ord2group2 nvarchar(50) 
set @ord2group2 = '' 
declare @sys_recid bigint 
set @sys_recid = 0 
  
 --- 以下是预处理事件中的临时表
 
exec drop_temp_table '#master' 
select * into #master from order_32 where ord_id=@ordid 
 ---- 以下是开发人员写的 before link job 事件 --------------
 update b
set b.ord_sfrz = '是'
from #master a, order_30 b
where a.ord_rordid = b.ord_id
 ---- 以上是开发人员写的 before libk job 事件 --------------
 
  
 
update old set 
ord_createcuid=case when new.ord_createcuid is null or new.ord_createcuid = -999999999  then old.ord_createcuid else new.ord_createcuid end,ord_createdpid=case when new.ord_createdpid is null or new.ord_createdpid = -999999999  then old.ord_createdpid else new.ord_createdpid end,ord_fbizid=case when new.ord_fbizid is null or new.ord_fbizid = -999999999  then old.ord_fbizid else new.ord_fbizid end,ord_ford2tag=case when new.ord_ford2tag is null or new.ord_ford2tag = -999999999  then old.ord_ford2tag else new.ord_ford2tag end,ord_noi=case when new.ord_noi is null or new.ord_noi = -999999999  then old.ord_noi else new.ord_noi end,ord_rbizid=case when new.ord_rbizid is null or new.ord_rbizid = -999999999  then old.ord_rbizid else new.ord_rbizid end,ord_dpid=case when new.ord_dpid is null or new.ord_dpid = -999999999  then old.ord_dpid else new.ord_dpid end,ord_frubmdpid=case when new.ord_frubmdpid is null or new.ord_frubmdpid = -999999999  then old.ord_frubmdpid else new.ord_frubmdpid end,ord_frugsdpid=case when new.ord_frugsdpid is null or new.ord_frugsdpid = -999999999  then old.ord_frugsdpid else new.ord_frugsdpid end,ord_frugwdpid=case when new.ord_frugwdpid is null or new.ord_frugwdpid = -999999999  then old.ord_frugwdpid else new.ord_frugwdpid end,ord_fruzbdpid=case when new.ord_fruzbdpid is null or new.ord_fruzbdpid = -999999999  then old.ord_fruzbdpid else new.ord_fruzbdpid end,ord_rord2tag=case when new.ord_rord2tag is null or new.ord_rord2tag = -999999999  then old.ord_rord2tag else new.ord_rord2tag end,ord_security=case when new.ord_security is null or new.ord_security = -999999999  then old.ord_security else new.ord_security end,ord_style=case when new.ord_style is null or new.ord_style = -999999999  then old.ord_style else new.ord_style end,ord_templateid=case when new.ord_templateid is null or new.ord_templateid = -999999999  then old.ord_templateid else new.ord_templateid end,ord_syqx=case when new.ord_syqx is null or new.ord_syqx = -999999999  then old.ord_syqx else new.ord_syqx end,ord_cuid=case when new.ord_cuid is null or new.ord_cuid = -999999999  then old.ord_cuid else new.ord_cuid end,ord_enddate=case when new.ord_enddate is null or new.ord_enddate = @nonedate then old.ord_enddate else new.ord_enddate end,ord_rzsj=case when new.ord_rzsj is null or new.ord_rzsj = @nonedate then old.ord_rzsj else new.ord_rzsj end,ord_htjzrq=case when new.ord_htjzrq is null or new.ord_htjzrq = @nonedate then old.ord_htjzrq else new.ord_htjzrq end,ord_htsxrq=case when new.ord_htsxrq is null or new.ord_htsxrq = @nonedate then old.ord_htsxrq else new.ord_htsxrq end,ord_syjdate=case when new.ord_syjdate is null or new.ord_syjdate = @nonedate then old.ord_syjdate else new.ord_syjdate end,ord_gdjbf=case when new.ord_gdjbf is null or new.ord_gdjbf = -999999999  then old.ord_gdjbf else new.ord_gdjbf end,ord_gwgz=case when new.ord_gwgz is null or new.ord_gwgz = -999999999  then old.ord_gwgz else new.ord_gwgz end,ord_hj=case when new.ord_hj is null or new.ord_hj = -999999999  then old.ord_hj else new.ord_hj end,ord_jtbt=case when new.ord_jtbt is null or new.ord_jtbt = -999999999  then old.ord_jtbt else new.ord_jtbt end,ord_jxgz=case when new.ord_jxgz is null or new.ord_jxgz = -999999999  then old.ord_jxgz else new.ord_jxgz end,ord_qt=case when new.ord_qt is null or new.ord_qt = -999999999  then old.ord_qt else new.ord_qt end,ord_qt1=case when new.ord_qt1 is null or new.ord_qt1 = -999999999  then old.ord_qt1 else new.ord_qt1 end,ord_skbx=case when new.ord_skbx is null or new.ord_skbx = -999999999  then old.ord_skbx else new.ord_skbx end,ord_txbt=case when new.ord_txbt is null or new.ord_txbt = -999999999  then old.ord_txbt else new.ord_txbt end,ord_wzrgz=case when new.ord_wzrgz is null or new.ord_wzrgz = -999999999  then old.ord_wzrgz else new.ord_wzrgz end,ord_cbid=case when new.ord_cbid is null or new.ord_cbid = -999999999  then old.ord_cbid else new.ord_cbid end,ord_ford2id=case when new.ord_ford2id is null or new.ord_ford2id = -999999999  then old.ord_ford2id else new.ord_ford2id end,ord_fordid=case when new.ord_fordid is null or new.ord_fordid = -999999999  then old.ord_fordid else new.ord_fordid end,ord_rord2id=case when new.ord_rord2id is null or new.ord_rord2id = -999999999  then old.ord_rord2id else new.ord_rord2id end,ord_rordid=case when new.ord_rordid is null or new.ord_rordid = -999999999  then old.ord_rordid else new.ord_rordid end,ord_fjbid=case when new.ord_fjbid is null or new.ord_fjbid = -999999999  then old.ord_fjbid else new.ord_fjbid end,ord_bc_departid=case when new.ord_bc_departid is null or new.ord_bc_departid = -999999999  then old.ord_bc_departid else new.ord_bc_departid end,ord_dp_otid=case when new.ord_dp_otid is null or new.ord_dp_otid = -999999999  then old.ord_dp_otid else new.ord_dp_otid end,ord_ftitleid=case when new.ord_ftitleid is null or new.ord_ftitleid = -999999999  then old.ord_ftitleid else new.ord_ftitleid end,ord_dq_bmdpid=case when new.ord_dq_bmdpid is null or new.ord_dq_bmdpid = -999999999  then old.ord_dq_bmdpid else new.ord_dq_bmdpid end,ord_bmdpid=case when new.ord_bmdpid is null or new.ord_bmdpid = -999999999  then old.ord_bmdpid else new.ord_bmdpid end,ord_fbcid=case when new.ord_fbcid is null or new.ord_fbcid = -999999999  then old.ord_fbcid else new.ord_fbcid end,ord_brccuid=case when new.ord_brccuid is null or new.ord_brccuid = -999999999  then old.ord_brccuid else new.ord_brccuid end,ord_obcid=case when new.ord_obcid is null or new.ord_obcid = -999999999  then old.ord_obcid else new.ord_obcid end,ord_odpid=case when new.ord_odpid is null or new.ord_odpid = -999999999  then old.ord_odpid else new.ord_odpid end,ord_zpordid=case when new.ord_zpordid is null or new.ord_zpordid = -999999999  then old.ord_zpordid else new.ord_zpordid end,ord_jtgsbcid=case when new.ord_jtgsbcid is null or new.ord_jtgsbcid = -999999999  then old.ord_jtgsbcid else new.ord_jtgsbcid end,ord_gwid=case when new.ord_gwid is null or new.ord_gwid = -999999999  then old.ord_gwid else new.ord_gwid end,ord_ftype=case when new.ord_ftype is null or new.ord_ftype = '_none_'  then old.ord_ftype else new.ord_ftype end,ord_key=case when new.ord_key is null or new.ord_key = '_none_'  then old.ord_key else new.ord_key end,ord_no=case when new.ord_no is null or new.ord_no = '_none_'  then old.ord_no else new.ord_no end,ord_rtype=case when new.ord_rtype is null or new.ord_rtype = '_none_'  then old.ord_rtype else new.ord_rtype end,ord_createbizids=case when new.ord_createbizids is null or new.ord_createbizids = '_none_'  then old.ord_createbizids else new.ord_createbizids end,ord_branch=case when new.ord_branch is null or new.ord_branch = '_none_'  then old.ord_branch else new.ord_branch end,ord_createdepart=case when new.ord_createdepart is null or new.ord_createdepart = '_none_'  then old.ord_createdepart else new.ord_createdepart end,ord_creator=case when new.ord_creator is null or new.ord_creator = '_none_'  then old.ord_creator else new.ord_creator end,ord_cucode=case when new.ord_cucode is null or new.ord_cucode = '_none_'  then old.ord_cucode else new.ord_cucode end,ord_cuname=case when new.ord_cuname is null or new.ord_cuname = '_none_'  then old.ord_cuname else new.ord_cuname end,ord_sfzh=case when new.ord_sfzh is null or new.ord_sfzh = '_none_'  then old.ord_sfzh else new.ord_sfzh end,ord_rzzb=case when new.ord_rzzb is null or new.ord_rzzb = '_none_'  then old.ord_rzzb else new.ord_rzzb end,ord_lxdh=case when new.ord_lxdh is null or new.ord_lxdh = '_none_'  then old.ord_lxdh else new.ord_lxdh end,ord_bgid=case when new.ord_bgid is null or new.ord_bgid = '_none_'  then old.ord_bgid else new.ord_bgid end,ord_zkr=case when new.ord_zkr is null or new.ord_zkr = '_none_'  then old.ord_zkr else new.ord_zkr end,ord_oadepart=case when new.ord_oadepart is null or new.ord_oadepart = '_none_'  then old.ord_oadepart else new.ord_oadepart end,ord_cutitle=case when new.ord_cutitle is null or new.ord_cutitle = '_none_'  then old.ord_cutitle else new.ord_cutitle end,ord_rzgs=case when new.ord_rzgs is null or new.ord_rzgs = '_none_'  then old.ord_rzgs else new.ord_rzgs end,ord_age=case when new.ord_age is null or new.ord_age = '_none_'  then old.ord_age else new.ord_age end,ord_depart=case when new.ord_depart is null or new.ord_depart = '_none_'  then old.ord_depart else new.ord_depart end,ord_empname=case when new.ord_empname is null or new.ord_empname = '_none_'  then old.ord_empname else new.ord_empname end,ord_yxqh=case when new.ord_yxqh is null or new.ord_yxqh = '_none_'  then old.ord_yxqh else new.ord_yxqh end,ord_hm=case when new.ord_hm is null or new.ord_hm = '_none_'  then old.ord_hm else new.ord_hm end,ord_khsf=case when new.ord_khsf is null or new.ord_khsf = '_none_'  then old.ord_khsf else new.ord_khsf end,ord_qh=case when new.ord_qh is null or new.ord_qh = '_none_'  then old.ord_qh else new.ord_qh end,ord_yxkh=case when new.ord_yxkh is null or new.ord_yxkh = '_none_'  then old.ord_yxkh else new.ord_yxkh end,ord_oabranch=case when new.ord_oabranch is null or new.ord_oabranch = '_none_'  then old.ord_oabranch else new.ord_oabranch end,ord_rzzx=case when new.ord_rzzx is null or new.ord_rzzx = '_none_'  then old.ord_rzzx else new.ord_rzzx end,ord_xcdj=case when new.ord_xcdj is null or new.ord_xcdj = '_none_'  then old.ord_xcdj else new.ord_xcdj end,ord_zw=case when new.ord_zw is null or new.ord_zw = '_none_'  then old.ord_zw else new.ord_zw end,ord_yxhm=case when new.ord_yxhm is null or new.ord_yxhm = '_none_'  then old.ord_yxhm else new.ord_yxhm end,ord_yxkhsf=case when new.ord_yxkhsf is null or new.ord_yxkhsf = '_none_'  then old.ord_yxkhsf else new.ord_yxkhsf end,ord_yxkhx=case when new.ord_yxkhx is null or new.ord_yxkhx = '_none_'  then old.ord_yxkhx else new.ord_yxkhx end,ord_rzpq=case when new.ord_rzpq is null or new.ord_rzpq = '_none_'  then old.ord_rzpq else new.ord_rzpq end,ord_zhuwu=case when new.ord_zhuwu is null or new.ord_zhuwu = '_none_'  then old.ord_zhuwu else new.ord_zhuwu end,ord_zj=case when new.ord_zj is null or new.ord_zj = '_none_'  then old.ord_zj else new.ord_zj end,ord_rzbm=case when new.ord_rzbm is null or new.ord_rzbm = '_none_'  then old.ord_rzbm else new.ord_rzbm end,ord_rzfs=case when new.ord_rzfs is null or new.ord_rzfs = '_none_'  then old.ord_rzfs else new.ord_rzfs end,ord_rztx=case when new.ord_rztx is null or new.ord_rztx = '_none_'  then old.ord_rztx else new.ord_rztx end,ord_note=case when new.ord_note is null or new.ord_note = '_none_'  then old.ord_note else new.ord_note end,ord_xzdj=case when new.ord_xzdj is null or new.ord_xzdj = '_none_'  then old.ord_xzdj else new.ord_xzdj end,ord_zhiji=case when new.ord_zhiji is null or new.ord_zhiji = '_none_'  then old.ord_zhiji else new.ord_zhiji end,ord_zhiwu=case when new.ord_zhiwu is null or new.ord_zhiwu = '_none_'  then old.ord_zhiwu else new.ord_zhiwu end,ord_bz=case when new.ord_bz is null or new.ord_bz = '_none_'  then old.ord_bz else new.ord_bz end,ord_rzdp=case when new.ord_rzdp is null or new.ord_rzdp = '_none_'  then old.ord_rzdp else new.ord_rzdp end,ord_status=case when new.ord_status is null or new.ord_status = '_none_'  then old.ord_status else new.ord_status end,ord_template=case when new.ord_template is null or new.ord_template = '_none_'  then old.ord_template else new.ord_template end,ord_title=case when new.ord_title is null or new.ord_title = '_none_'  then old.ord_title else new.ord_title end,ord_type=case when new.ord_type is null or new.ord_type = '_none_'  then old.ord_type else new.ord_type end,ord_yglx=case when new.ord_yglx is null or new.ord_yglx = '_none_'  then old.ord_yglx else new.ord_yglx end,ord_ndepart=case when new.ord_ndepart is null or new.ord_ndepart = '_none_'  then old.ord_ndepart else new.ord_ndepart end
from order_32 old , #master new  where old.ord_id=new.ord_id 

 
--- 清除临时表 
exec drop_temp_table '#master' 

set nocount off 
end