IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_prd1_full]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_prd1_full]
GO
-- 生成时间:2018-05-11 10:25:58 by ebs-core  
create  procedure [dbo].[mps_prd1_full](
@cmpid int,  
    @prdid bigint, 
    @useruid int,
    @canedit int ) 
as  
begin  
set nocount on 
-- 首先取模板  t1  
declare @pcid int 
declare @pctag int
select @pctag=prd_tag,@pcid=prd_pcid from mps_prd1 where prd_id=@prdid 
if (@canedit=1)
select top 1 * from mps_template where  tmp_cmpid=@cmpid and tmp_type='prddisp' and tmp_objid=@pcid  
else 
select top 1 * from mps_template where  tmp_cmpid=@cmpid and tmp_type='prd' and tmp_objid=@pcid  


-- 返回客户定义表t2  
   select * from mps_prdctg where pc_id=@pcid 
   
  
  -- 返回客户的特殊权限  t3 
    select * from mps_prd1_users where prdp_prdid=@prdid and prdp_cuid=@useruid 
    
    --返回业务单数据 t4
    select * from mps_prd1 where prd_id = @prdid 
    -- 获取业务表主根据扩展数据  t5
    select  * from mps_prd1_0 where prd3_prdid = @prdid 
    
    --返回所有附件  t6
    select *, da_categoryid as datagroup from mps_attach where da_cmpid = @cmpid and da_type = 'prd'+convert(varchar(10),@pctag)   and da_objid = @prdid and da_objid2 = 0 order by da_categoryid 
      
     

--明细表数据
 
----以下是数据源 

--- 以下获取用户自定义SQL afterloaded 


--- 以上获取用户自定义SQL afterloaded 
set nocount off
end