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

-- 生成时间:2018-11-21 12:52:14 by ebs-core  
CREATE  procedure mps_prd1_modify(
@cmpid int,
@branchid int,
@userdpid int,
@useruid int,
@userotid int,
@prdid bigint, @sourcefield varchar(50)=default,
@prd_abstract nvarchar(200)=default,
@prd_area nvarchar(100)=default,
@prd_attachi int=default,
@prd_barcode varchar(32)=default,
@prd_branch nvarchar(50)=default,
@prd_brand nvarchar(100)=default,
@prd_click int=default,
@prd_code varchar(32)=default,
@prd_createcuid int=default,
@prd_createdepart nvarchar(50)=default,
@prd_createdpid int=default,
@prd_creator nvarchar(50)=default,
@prd_cuid int=default,
@prd_cuname nvarchar(50)=default,
@prd_depart nvarchar(50)=default,
@prd_dpid int=default,
@prd_expireddays int=default,
@prd_factory nvarchar(100)=default,
@prd_fprdid bigint=default,
@prd_icon varchar(200)=default,
@prd_icon2 varchar(200)=default,
@prd_jclx nvarchar(100)=default,
@prd_label nvarchar(200)=default,
@prd_lrbz_bak_bak_20181112102006903 nvarchar(500)=default,
@prd_model nvarchar(100)=default,
@prd_pack nvarchar(100)=default,
@prd_pcid int=default,
@prd_price decimal(18,4)=default,
@prd_productdate datetime=default,
@prd_security int=default,
@prd_serialno int=default,
@prd_spec nvarchar(100)=default,
@prd_title nvarchar(100)=default,
@prd_type nvarchar(50)=default,
@prd_unit nvarchar(50)=default,
@prd_xmcode bigint=default,
@prd_caption nvarchar(50)=default,
@prd_use int=default,
@prd_xmmc nvarchar(100)=default,
@prd_lrbz nvarchar(MAX)=default,
@prd_lrbz_bak_bak_20181121094543857 nvarchar(2000)=default,
@prd_dsr nvarchar(100)=default,
@prd_dzc nvarchar(100)=default,
@prd_qydd nvarchar(100)=default,
@prd_lrbz_bak nvarchar(MAX)=default ) 
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 @pcid int 
 select top 1 @pcid=prd_pcid,@bmcode = pc_bmcode from mps_prd1,mps_prdctg where prd_id=@prdid and prd_pcid=pc_id and (prd_code='' or prd_code like '%临%')
 set @pcid = isnull(@pcid,0) 
 if (@pcid>0) 
 begin
 if (@bmcode>'') 
 begin
exec mps_bm_getorset @cmpid,'prd',@pcid,@prdid,@useruid,@bmcode,0,@newno output,1
set @prd_code = @newno 
end 
end 

 --- 以下是预处理事件中的临时表
 update mps_prd1 set 
prd_abstract=case when @prd_abstract is null or @prd_abstract = '_none_'  then prd_abstract else @prd_abstract end,prd_area=case when @prd_area is null or @prd_area = '_none_'  then prd_area else @prd_area end,prd_attachi=case when @prd_attachi is null or @prd_attachi = -999999999  then prd_attachi else @prd_attachi end,prd_barcode=case when @prd_barcode is null or @prd_barcode = '_none_'  then prd_barcode else @prd_barcode end,prd_branch=case when @prd_branch is null or @prd_branch = '_none_'  then prd_branch else @prd_branch end,prd_brand=case when @prd_brand is null or @prd_brand = '_none_'  then prd_brand else @prd_brand end,prd_click=case when @prd_click is null or @prd_click = -999999999  then prd_click else @prd_click end,prd_code=case when @prd_code is null or @prd_code = '_none_'  then prd_code else @prd_code end,prd_createcuid=case when @prd_createcuid is null or @prd_createcuid = -999999999  then prd_createcuid else @prd_createcuid end,prd_createdepart=case when @prd_createdepart is null or @prd_createdepart = '_none_'  then prd_createdepart else @prd_createdepart end,prd_createdpid=case when @prd_createdpid is null or @prd_createdpid = -999999999  then prd_createdpid else @prd_createdpid end,prd_creator=case when @prd_creator is null or @prd_creator = '_none_'  then prd_creator else @prd_creator end,prd_cuid=case when @prd_cuid is null or @prd_cuid = -999999999  then prd_cuid else @prd_cuid end,prd_cuname=case when @prd_cuname is null or @prd_cuname = '_none_'  then prd_cuname else @prd_cuname end,prd_depart=case when @prd_depart is null or @prd_depart = '_none_'  then prd_depart else @prd_depart end,prd_dpid=case when @prd_dpid is null or @prd_dpid = -999999999  then prd_dpid else @prd_dpid end,prd_expireddays=case when @prd_expireddays is null or @prd_expireddays = -999999999  then prd_expireddays else @prd_expireddays end,prd_factory=case when @prd_factory is null or @prd_factory = '_none_'  then prd_factory else @prd_factory end,prd_fprdid=case when @prd_fprdid is null or @prd_fprdid = -999999999  then prd_fprdid else @prd_fprdid end,prd_icon=case when @prd_icon is null or @prd_icon = '_none_'  then prd_icon else @prd_icon end,prd_icon2=case when @prd_icon2 is null or @prd_icon2 = '_none_'  then prd_icon2 else @prd_icon2 end,prd_jclx=case when @prd_jclx is null or @prd_jclx = '_none_'  then prd_jclx else @prd_jclx end,prd_label=case when @prd_label is null or @prd_label = '_none_'  then prd_label else @prd_label end,prd_lrbz_bak_bak_20181112102006903=case when @prd_lrbz_bak_bak_20181112102006903 is null or @prd_lrbz_bak_bak_20181112102006903 = '_none_'  then prd_lrbz_bak_bak_20181112102006903 else @prd_lrbz_bak_bak_20181112102006903 end,prd_model=case when @prd_model is null or @prd_model = '_none_'  then prd_model else @prd_model end,prd_pack=case when @prd_pack is null or @prd_pack = '_none_'  then prd_pack else @prd_pack end,prd_pcid=case when @prd_pcid is null or @prd_pcid = -999999999  then prd_pcid else @prd_pcid end,prd_price=case when @prd_price is null or @prd_price = -999999999  then prd_price else @prd_price end,prd_productdate=case when @prd_productdate is null or @prd_productdate <= @nonedate then prd_productdate else @prd_productdate end,prd_security=case when @prd_security is null or @prd_security = -999999999  then prd_security else @prd_security end,prd_serialno=case when @prd_serialno is null or @prd_serialno = -999999999  then prd_serialno else @prd_serialno end,prd_spec=case when @prd_spec is null or @prd_spec = '_none_'  then prd_spec else @prd_spec end,prd_title=case when @prd_title is null or @prd_title = '_none_'  then prd_title else @prd_title end,prd_type=case when @prd_type is null or @prd_type = '_none_'  then prd_type else @prd_type end,prd_unit=case when @prd_unit is null or @prd_unit = '_none_'  then prd_unit else @prd_unit end,prd_xmcode=case when @prd_xmcode is null or @prd_xmcode = -999999999  then prd_xmcode else @prd_xmcode end,prd_caption=case when @prd_caption is null or @prd_caption = '_none_'  then prd_caption else @prd_caption end,prd_use=case when @prd_use is null or @prd_use = -999999999  then prd_use else @prd_use end,prd_xmmc=case when @prd_xmmc is null or @prd_xmmc = '_none_'  then prd_xmmc else @prd_xmmc end,prd_lrbz=case when @prd_lrbz is null or @prd_lrbz = '_none_'  then prd_lrbz else @prd_lrbz end,prd_lrbz_bak_bak_20181121094543857=case when @prd_lrbz_bak_bak_20181121094543857 is null or @prd_lrbz_bak_bak_20181121094543857 = '_none_'  then prd_lrbz_bak_bak_20181121094543857 else @prd_lrbz_bak_bak_20181121094543857 end,prd_dsr=case when @prd_dsr is null or @prd_dsr = '_none_'  then prd_dsr else @prd_dsr end,prd_dzc=case when @prd_dzc is null or @prd_dzc = '_none_'  then prd_dzc else @prd_dzc end,prd_qydd=case when @prd_qydd is null or @prd_qydd = '_none_'  then prd_qydd else @prd_qydd end,prd_lrbz_bak=case when @prd_lrbz_bak is null or @prd_lrbz_bak = '_none_'  then prd_lrbz_bak else @prd_lrbz_bak end,
prd_updated=getdate() 
where prd_id=@prdid 
 if (@operation='continue') 
 begin
 set @nonedate = @nonedate 
 
 select 'ok' operation, '' errorinfo 
end  else 
begin
select @operation operation, @errorinfo errorinfo  
end

 
set nocount off 
end