IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_gen_dptdelete_after]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_gen_dptdelete_after]
GO
create procedure [dbo].[mps_gen_dptdelete_after](
@cmpid int
)
as
begin
set nocount on
declare @tbname varchar(50)
declare @dbname varchar(50)
declare @fkey   varchar(50) 
exec sys_sql_getTableNamePk @cmpid,'dpt',@cmpid,0,@tbname output,@fkey output ,@dbname output 
declare @sql nvarchar(MAX) 

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


set @sql = N'
-- 生成时间:'+convert(varchar(20),getdate(),120)+N' by ebs-core  
'
if (dbo.checkprocedure(@tbname+'_delete_after')=0) set @sql=@sql+'alter ' else set @sql=@sql+'create '
set @sql = @sql+' procedure '+@tbname+'_delete_after (
     @cmpid int,
     @branchid int,
     @userdpid int,
     @useruid int,
     @userotid int,
     @dpid bigint
  ) 
as  
begin  
set nocount on  
declare @sys_recid bigint 
set @sys_recid = 0 
 declare @nonedate datetime 
set @nonedate = CONVERT(datetime,''1910-1-1'')
 --- 以下是预处理事件中的临时表
 --- #old   在主体中已经生成
 '
 
 
set @sql=@sql+N'
 ---- 以下是开发人员写的 after delte details order 事件 --------------
 '
 + dbo.mps_sys_getusercode('dpt.afterdelete',@cmpid,0) +N'
 ---- 以上是开发人员写的 after delte details order 事件 --------------
 
 ' 
 
set @sql = @sql +N'
set nocount off 
end
'
exec myprint @sql 
execute(@sql) 
set nocount off 
end