IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_gen_shpmodify_before]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_gen_shpmodify_before]
GO
create procedure [dbo].[mps_gen_shpmodify_before](
@cmpid int
)
as
begin
set nocount on
declare @tbname varchar(50)
declare @dbname varchar(50)
declare @fkey   varchar(50) 

exec sys_sql_getTableNamePk @cmpid,'shp',@cmpid,0,@tbname output,@fkey output ,@dbname output 

declare @sql nvarchar(MAX) 
declare @ss nvarchar(MAX) 

if (dbo.mps_sys_checkkeywords('shp.beforemodify',@cmpid,0,'','')<>0) 
begin
set @sql = 'drop procedure '+@tbname+'_shpmodify_before' 
if (dbo.checkprocedure(@tbname+'_shpmodify_before')=0) execute(@sql)  
return 
end

set @sql = N'
-- 生成时间:'+convert(varchar(20),getdate(),120)+N' by ebs-core  
'
if (dbo.checkprocedure(@tbname+'_shpmodify_before')=0) set @sql=@sql+'alter ' else set @sql=@sql+'create '
set @sql = @sql+' procedure '+@tbname+N'_shpmodify_before(
     @cmpid int,
     @branchid int,
     @userdpid int,
     @useruid int,
     @userotid int,
     @dpid bigint,
     @operation varchar(50) output,
     @errorinfo nvarchar(4000) output
  ) 
as  
begin  
set nocount on  

declare @sys_recid bigint 
set @sys_recid = 0 
 declare @nonedate datetime 
set @nonedate = CONVERT(datetime,''1910-1-1'')
 set @operation = ''continue''
 set @errorinfo = '''' 
 --- 以下是预处理事件中的临时表
 --- #old 与 #new 在主体中已经生成
 '

set @sql=@sql+N'
 ---- 以下是开发人员写的 before modify order 事件 --------------
 '
 + dbo.mps_sys_getusercode('shp.beforemodify',@cmpid,0) +N'
 ---- 以上是开发人员写的 before modify order 事件 --------------
 
 if (@operation=''continue'') 
 begin
 set @sys_recid=@sys_recid  -- here useless 
 ' 

set @sql = @sql +N'
end 
--- 清除临时表 
' 
 
set @sql = @sql +N'
set nocount off 
end
'
exec myprint @sql 
execute(@sql)
set nocount off 
end