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

-- 生成时间:2018-11-28 11:55:07 by ebs-core  
CREATE  procedure order_255_check(
     @cmpid int,
     @branchid int,
     @userdpid int,
     @useruid int,
     @userotid int,
     @jbid bigint,
     @ordid bigint,
     @operation varchar(50) output,
     @errorinfo nvarchar(4000) output
  ) 
as  
begin  
set nocount on  
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
declare @ord2group2 nvarchar(50) 
set @ord2group2 = '' 
declare @sys_recid bigint 
set @sys_recid = 0 
 declare @nonedate datetime 
set @nonedate = CONVERT(datetime,'1910-1-1')
 set @operation = 'continue'
 set @errorinfo = '' 
 --- 以下是预处理事件中的临时表
 
exec drop_temp_table '#detail2' 
select * into #detail2 from order_255_2 with(nolock) where ord2_ordid=@ordid  

 ---- 以下是开发人员写的 check order 事件 --------------
 if exists (select 1 from #detail2 where ord2_jcqk ='不合格' and ord2_xwwcsj = '1900-01-01 00:00:00')
begin
    set @operation  = 'abort'
    set @errorinfo = '选择不合格后，必须填写完成时间！'
end
 ---- 以上是开发人员写的 check order 事件 --------------
 
 if (@operation='continue') 
 begin
 set @sys_recid=@sys_recid  -- here useless 
 
end 
--- 清除临时表 
exec drop_temp_table '#detail2'

set nocount off 
end