IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_gen_prdmodify0]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_gen_prdmodify0]
GO
create procedure [dbo].[mps_gen_prdmodify0](
@cmpid int,
@pcid int
)
as
begin
set nocount on
declare @s1 nvarchar(100) 
declare @tbname varchar(50)
declare @dbname varchar(50)
declare @fkey   varchar(50) 
declare @mctid int 
set @mctid = @pcid * (-1) 
exec sys_sql_getTableNamePk @cmpid,'prd',@mctid,0,@tbname output,@fkey output ,@dbname output 

declare @sql nvarchar(MAX) 
set @sql = N'
-- 生成时间:'+convert(varchar(20),getdate(),120)+N' by ebs-core  
'
if (dbo.checkprocedure(@tbname+'_modify_0')=0) set @sql=@sql+'alter ' else set @sql=@sql+'create '
set @sql = @sql+' procedure '+@tbname+N'_modify_0(
     @prdid bigint, 
     @idname varchar(50), 
     @text text ) 
as  
begin  
declare @id3 bigint 
select top 1 @id3 = prd3_id from '+@dbname+@tbname+N'_0 where prd3_prdid = @prdid  and prd3_idname=@idname 
set @id3 = isnull(@id3, 0) 
if (@id3 = 0) 
begin 
insert into '+@dbname+@tbname+N'_0(prd3_prdid, prd3_idname, prd3_text) values(@prdid, @idname, @text) 
end else 
begin 
update '+@dbname+@tbname+'_0 set prd3_text = @text where prd3_id = @id3 
end 
end 
 '
exec myprint @sql 
execute(@sql)
-- 生成mps_sql 
set @sql = ' exec mps_sys_gen_mpssql '+CONVERT(varchar(10),@cmpid)+','''+@tbname+N'_modify_0'',
''@prdid bigint,@idname varchar(50),@text text''' 
execute(@sql)
set nocount off 
end