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

-- 生成时间:2018-05-03 10:51:32 by ebs-core  
CREATE  procedure order_30_modify_10(
@ord2id bigint, 
@cmpid int, 
@branchid bigint, 
@userdpid bigint, 
@userotid bigint, 
@useruid int, 
@jbid bigint, 
@ordid bigint, 
@ord2tag int, 
@ord2_fbizid int,@ord2_ford2tag int,@ord2_order int,@ord2_rbizid int,@ord2_rord2tag int,@ord2_xzrs int,@ord2_jzrq datetime,@ord2_ksrq datetime,@ord2_xc decimal(18,2),@ord2_fatherord2id bigint,@ord2_ford2id bigint,@ord2_fordid bigint,@ord2_rord2id bigint,@ord2_rordid bigint,@ord2_code varchar(50),@ord2_ftype varchar(10),@ord2_key varchar(30),@ord2_rtype varchar(10),@ord2_tags varchar(100),@ord2_bz nvarchar(100),@ord2_caption nvarchar(100),@ord2_dwmc nvarchar(100),@ord2_job nvarchar(2000),@ord2_reason nvarchar(100),@ord2_status nvarchar(30),@ord2_szbm nvarchar(100),@ord2_title nvarchar(100),@ord2_gzxc nvarchar(100),@ord2_hbsj nvarchar(100),@ord2_zzsj nvarchar(100) ) 
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 
 declare @operation varchar(50)
 declare @errorinfo nvarchar(4000) 
 set @operation = 'continue' 
set @errorinfo = '' 
 --- 以下是预处理事件中的临时表
 declare @needreturn int 
 set @needreturn = 1
 if (@ord2id=0)  -- 如果=0
 begin
 set @ord2id=-1
 set @needreturn = 0
 exec order_30_10_newdetail @cmpid , @branchid , @userdpid, @useruid , @userotid, @jbid , @ordid ,@ord2tag ,@ord2id output , '' 
 if (@ord2id<=0) set @ord2id=0 
 end 
 update order_30_10 set 
ord2_fbizid=case when @ord2_fbizid is null or @ord2_fbizid = -999999999  then ord2_fbizid else @ord2_fbizid end,ord2_ford2tag=case when @ord2_ford2tag is null or @ord2_ford2tag = -999999999  then ord2_ford2tag else @ord2_ford2tag end,ord2_order=case when @ord2_order is null or @ord2_order = -999999999  then ord2_order else @ord2_order end,ord2_rbizid=case when @ord2_rbizid is null or @ord2_rbizid = -999999999  then ord2_rbizid else @ord2_rbizid end,ord2_rord2tag=case when @ord2_rord2tag is null or @ord2_rord2tag = -999999999  then ord2_rord2tag else @ord2_rord2tag end,ord2_xzrs=case when @ord2_xzrs is null or @ord2_xzrs = -999999999  then ord2_xzrs else @ord2_xzrs end,ord2_jzrq=case when @ord2_jzrq is null or @ord2_jzrq = @nonedate then ord2_jzrq else @ord2_jzrq end,ord2_ksrq=case when @ord2_ksrq is null or @ord2_ksrq = @nonedate then ord2_ksrq else @ord2_ksrq end,ord2_xc=case when @ord2_xc is null or @ord2_xc = -999999999  then ord2_xc else @ord2_xc end,ord2_fatherord2id=case when @ord2_fatherord2id is null or @ord2_fatherord2id = -999999999  then ord2_fatherord2id else @ord2_fatherord2id end,ord2_ford2id=case when @ord2_ford2id is null or @ord2_ford2id = -999999999  then ord2_ford2id else @ord2_ford2id end,ord2_fordid=case when @ord2_fordid is null or @ord2_fordid = -999999999  then ord2_fordid else @ord2_fordid end,ord2_rord2id=case when @ord2_rord2id is null or @ord2_rord2id = -999999999  then ord2_rord2id else @ord2_rord2id end,ord2_rordid=case when @ord2_rordid is null or @ord2_rordid = -999999999  then ord2_rordid else @ord2_rordid end,ord2_code=case when @ord2_code is null or @ord2_code = '_none_'  then ord2_code else @ord2_code end,ord2_ftype=case when @ord2_ftype is null or @ord2_ftype = '_none_'  then ord2_ftype else @ord2_ftype end,ord2_key=case when @ord2_key is null or @ord2_key = '_none_'  then ord2_key else @ord2_key end,ord2_rtype=case when @ord2_rtype is null or @ord2_rtype = '_none_'  then ord2_rtype else @ord2_rtype end,ord2_tags=case when @ord2_tags is null or @ord2_tags = '_none_'  then ord2_tags else @ord2_tags end,ord2_bz=case when @ord2_bz is null or @ord2_bz = '_none_'  then ord2_bz else @ord2_bz end,ord2_caption=case when @ord2_caption is null or @ord2_caption = '_none_'  then ord2_caption else @ord2_caption end,ord2_dwmc=case when @ord2_dwmc is null or @ord2_dwmc = '_none_'  then ord2_dwmc else @ord2_dwmc end,ord2_job=case when @ord2_job is null or @ord2_job = '_none_'  then ord2_job else @ord2_job end,ord2_reason=case when @ord2_reason is null or @ord2_reason = '_none_'  then ord2_reason else @ord2_reason end,ord2_status=case when @ord2_status is null or @ord2_status = '_none_'  then ord2_status else @ord2_status end,ord2_szbm=case when @ord2_szbm is null or @ord2_szbm = '_none_'  then ord2_szbm else @ord2_szbm end,ord2_title=case when @ord2_title is null or @ord2_title = '_none_'  then ord2_title else @ord2_title end,ord2_gzxc=case when @ord2_gzxc is null or @ord2_gzxc = '_none_'  then ord2_gzxc else @ord2_gzxc end,ord2_hbsj=case when @ord2_hbsj is null or @ord2_hbsj = '_none_'  then ord2_hbsj else @ord2_hbsj end,ord2_zzsj=case when @ord2_zzsj is null or @ord2_zzsj = '_none_'  then ord2_zzsj else @ord2_zzsj end,
ord2_updated=getdate() 
where ord2_id=@ord2id 
 if (@operation='continue') 
 begin
 set @nonedate=@nonedate   -- here useless 
 
 if (@needreturn=1) select 'ok' operation, '' errorinfo 
 else select * from order_30_10 where ord2_id=@ord2id
end  else 
begin
if (@needreturn=1) select @operation operation, @errorinfo errorinfo  
else select 0 none , 1 none1 where 1=0 
end
set nocount off 
end