IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_g_picksource_md]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_g_picksource_md]
GO
create procedure [dbo].[mps_g_picksource_md](
@cmpid int ,
@objmc varchar(30),
@objid int,
@objid2 int,
@datasource nvarchar(50) 
) as
begin
set nocount on
-- 如果是web或rfc
declare @type varchar(30) 
declare @svcname varchar(200) 
declare @ctgid int 
declare @bizsid int 
select @bizsid=bizs_id , @type=bizs_sourcetype , @ctgid=bizs_ctgid from mps_biztype_source with(nolock) 
where bizs_type=@objmc and bizs_bizid=@objid and ((bizs_ord2tag=0 and @objid2=0) or (bizs_ord2tag>0 and  @objid2>0))  and bizs_source=@datasource 

set @type = ISNULL(@type,'') 

if (@type='web' or @type='rfc' or @type='svc') 
begin
select @type = case when svc_type=0 then @type else svc_type end , @svcname=svc_name from ebs_kernel..pub_webservice with(nolock) where svc_id=@ctgid 
set @type = ISNULL(@type,'') 
set @svcname = ISNULL(@svcname,'') 
if (@type='') set @type=@objmc  
end
set @type = ISNULL(@type,'') 
if (@type='') set @type=@objmc  
select top 1 * , @type  svc_type , @svcname svc_name  
from mps_biztype_source with(nolock) 
where bizs_id=@bizsid
set nocount off 
end