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

-- 生成时间:2018-11-23 16:44:50 by ebs-core  
CREATE  procedure mps_prd2_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_caption nvarchar(50)=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_gzfl1 nvarchar(100)=default,
@prd_gzfl2 nvarchar(100)=default,
@prd_icon varchar(200)=default,
@prd_icon2 varchar(200)=default,
@prd_label nvarchar(200)=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_use int=default,
@prd_gzmc nvarchar(100)=default,
@prd_qtsm nvarchar(100)=default,
@prd_pp nvarchar(100)=default,
@prd_xh nvarchar(100)=default,
@prd_dhhm nvarchar(100)=default,
@prd_qt nvarchar(100)=default,
@prd_sjmc nvarchar(100)=default,
@prd_clff nvarchar(100)=default,
@prd_fwlx nvarchar(100)=default,
@prd_lx nvarchar(100)=default,
@prd_oldid bigint=default,
@prd_gl nvarchar(100)=default,
@prd_xh1 nvarchar(100)=default,
@prd_xh2 nvarchar(100)=default,
@prd_xh3 nvarchar(100)=default ) 
as  
begin  
set nocount on  

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
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_prd2,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_prd2 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_caption=case when @prd_caption is null or @prd_caption = '_none_'  then prd_caption else @prd_caption 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_gzfl1=case when @prd_gzfl1 is null or @prd_gzfl1 = '_none_'  then prd_gzfl1 else @prd_gzfl1 end,prd_gzfl2=case when @prd_gzfl2 is null or @prd_gzfl2 = '_none_'  then prd_gzfl2 else @prd_gzfl2 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_label=case when @prd_label is null or @prd_label = '_none_'  then prd_label else @prd_label 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_use=case when @prd_use is null or @prd_use = -999999999  then prd_use else @prd_use end,prd_gzmc=case when @prd_gzmc is null or @prd_gzmc = '_none_'  then prd_gzmc else @prd_gzmc end,prd_qtsm=case when @prd_qtsm is null or @prd_qtsm = '_none_'  then prd_qtsm else @prd_qtsm end,prd_pp=case when @prd_pp is null or @prd_pp = '_none_'  then prd_pp else @prd_pp end,prd_xh=case when @prd_xh is null or @prd_xh = '_none_'  then prd_xh else @prd_xh end,prd_dhhm=case when @prd_dhhm is null or @prd_dhhm = '_none_'  then prd_dhhm else @prd_dhhm end,prd_qt=case when @prd_qt is null or @prd_qt = '_none_'  then prd_qt else @prd_qt end,prd_sjmc=case when @prd_sjmc is null or @prd_sjmc = '_none_'  then prd_sjmc else @prd_sjmc end,prd_clff=case when @prd_clff is null or @prd_clff = '_none_'  then prd_clff else @prd_clff end,prd_fwlx=case when @prd_fwlx is null or @prd_fwlx = '_none_'  then prd_fwlx else @prd_fwlx end,prd_lx=case when @prd_lx is null or @prd_lx = '_none_'  then prd_lx else @prd_lx end,prd_oldid=case when @prd_oldid is null or @prd_oldid = -999999999  then prd_oldid else @prd_oldid end,prd_gl=case when @prd_gl is null or @prd_gl = '_none_'  then prd_gl else @prd_gl end,prd_xh1=case when @prd_xh1 is null or @prd_xh1 = '_none_'  then prd_xh1 else @prd_xh1 end,prd_xh2=case when @prd_xh2 is null or @prd_xh2 = '_none_'  then prd_xh2 else @prd_xh2 end,prd_xh3=case when @prd_xh3 is null or @prd_xh3 = '_none_'  then prd_xh3 else @prd_xh3 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