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

-- 生成时间:2018-05-08 15:18:01 by ebs-core  
CREATE  procedure mps_customer2_modify(
@cmpid int,
@branchid int,
@userdpid int,
@useruid int,
@userotid int,
@ccid bigint, 
@cc_accountperiod int,@cc_createcuid int,@cc_createdpid int,@cc_creditquantum int,@cc_cuid int,@cc_dpid int,@cc_fccid int,@cc_gender int,@cc_security int,@cc_use int,@cc_activetime datetime,@cc_birth datetime,@cc_score decimal(18,4),@cc_total decimal(18,4),@cc_value decimal(18,4),@cc_code varchar(50),@cc_contact varchar(50),@cc_email varchar(100),@cc_icon varchar(50),@cc_identno varchar(20),@cc_mobile varchar(18),@cc_monthday varchar(4),@cc_msnqq varchar(50),@cc_addr nvarchar(100),@cc_branch nvarchar(50),@cc_caption nvarchar(50),@cc_company nvarchar(50),@cc_createdepart nvarchar(50),@cc_creator nvarchar(50),@cc_type nvarchar(50),@cc_cuname nvarchar(50),@cc_depart nvarchar(50),@cc_identtype nvarchar(20),@cc_name nvarchar(50),@cc_source nvarchar(50),@cc_status nvarchar(50) ) 
as  
begin  
set nocount on  
declare @nonedate datetime 
set @nonedate = CONVERT(datetime,'1910-1-1')
 declare @operation varchar(50)
declare @errorinfo nvarchar(4000) 
 set @operation = 'continue' 
set @errorinfo = '' 

-- 处理编码
 declare @bmcode varchar(200) 
 declare @newno nvarchar(50) 
 declare @ctid int 
 select top 1 @ctid=cc_ctid,@bmcode = ct_bmcode from mps_customer2,mps_csttype where cc_id=@ccid and cc_ctid=ct_id and (cc_code='' or cc_code like '%临%')
 set @ctid = isnull(@ctid,0) 
 if (@ctid>0) 
 begin
exec mps_bm_getorset @cmpid,'cst',@ctid,@ccid,@useruid,@bmcode,0,@newno output,1
set @cc_code = @newno 
end 

 --- 以下是预处理事件中的临时表
 update mps_customer2 set 
cc_accountperiod=case when @cc_accountperiod is null or @cc_accountperiod = -999999999  then cc_accountperiod else @cc_accountperiod end,cc_createcuid=case when @cc_createcuid is null or @cc_createcuid = -999999999  then cc_createcuid else @cc_createcuid end,cc_createdpid=case when @cc_createdpid is null or @cc_createdpid = -999999999  then cc_createdpid else @cc_createdpid end,cc_creditquantum=case when @cc_creditquantum is null or @cc_creditquantum = -999999999  then cc_creditquantum else @cc_creditquantum end,cc_cuid=case when @cc_cuid is null or @cc_cuid = -999999999  then cc_cuid else @cc_cuid end,cc_dpid=case when @cc_dpid is null or @cc_dpid = -999999999  then cc_dpid else @cc_dpid end,cc_fccid=case when @cc_fccid is null or @cc_fccid = -999999999  then cc_fccid else @cc_fccid end,cc_gender=case when @cc_gender is null or @cc_gender = -999999999  then cc_gender else @cc_gender end,cc_security=case when @cc_security is null or @cc_security = -999999999  then cc_security else @cc_security end,cc_use=case when @cc_use is null or @cc_use = -999999999  then cc_use else @cc_use end,cc_activetime=case when @cc_activetime is null or @cc_activetime = @nonedate then cc_activetime else @cc_activetime end,cc_birth=case when @cc_birth is null or @cc_birth = @nonedate then cc_birth else @cc_birth end,cc_score=case when @cc_score is null or @cc_score = -999999999  then cc_score else @cc_score end,cc_total=case when @cc_total is null or @cc_total = -999999999  then cc_total else @cc_total end,cc_value=case when @cc_value is null or @cc_value = -999999999  then cc_value else @cc_value end,cc_code=case when @cc_code is null or @cc_code = '_none_'  then cc_code else @cc_code end,cc_contact=case when @cc_contact is null or @cc_contact = '_none_'  then cc_contact else @cc_contact end,cc_email=case when @cc_email is null or @cc_email = '_none_'  then cc_email else @cc_email end,cc_icon=case when @cc_icon is null or @cc_icon = '_none_'  then cc_icon else @cc_icon end,cc_identno=case when @cc_identno is null or @cc_identno = '_none_'  then cc_identno else @cc_identno end,cc_mobile=case when @cc_mobile is null or @cc_mobile = '_none_'  then cc_mobile else @cc_mobile end,cc_monthday=case when @cc_monthday is null or @cc_monthday = '_none_'  then cc_monthday else @cc_monthday end,cc_msnqq=case when @cc_msnqq is null or @cc_msnqq = '_none_'  then cc_msnqq else @cc_msnqq end,cc_addr=case when @cc_addr is null or @cc_addr = '_none_'  then cc_addr else @cc_addr end,cc_branch=case when @cc_branch is null or @cc_branch = '_none_'  then cc_branch else @cc_branch end,cc_caption=case when @cc_caption is null or @cc_caption = '_none_'  then cc_caption else @cc_caption end,cc_company=case when @cc_company is null or @cc_company = '_none_'  then cc_company else @cc_company end,cc_createdepart=case when @cc_createdepart is null or @cc_createdepart = '_none_'  then cc_createdepart else @cc_createdepart end,cc_creator=case when @cc_creator is null or @cc_creator = '_none_'  then cc_creator else @cc_creator end,cc_type=case when @cc_type is null or @cc_type = '_none_'  then cc_type else @cc_type end,cc_cuname=case when @cc_cuname is null or @cc_cuname = '_none_'  then cc_cuname else @cc_cuname end,cc_depart=case when @cc_depart is null or @cc_depart = '_none_'  then cc_depart else @cc_depart end,cc_identtype=case when @cc_identtype is null or @cc_identtype = '_none_'  then cc_identtype else @cc_identtype end,cc_name=case when @cc_name is null or @cc_name = '_none_'  then cc_name else @cc_name end,cc_source=case when @cc_source is null or @cc_source = '_none_'  then cc_source else @cc_source end,cc_status=case when @cc_status is null or @cc_status = '_none_'  then cc_status else @cc_status end,
cc_updated=getdate() 
where cc_id=@ccid 
 if (@operation='continue') 
 begin
 set @nonedate = @nonedate 
 
 select 'ok' operation, '' errorinfo 
end  else 
begin
select @operation operation, @errorinfo errorinfo  
end

 
set nocount off 
end