IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_update_weixin_count]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_update_weixin_count]
GO
 
CREATE procedure [dbo].[mps_update_weixin_count]   
@wx_id [int],  
@wx_cmpid [int],  
@wx_code [varchar](64) ,  
@wx_type [varchar](10) ,  
@wx_title [nvarchar](100) ,  
@wx_appid [int] ,  
@wx_token [varchar](64) ,  
@wx_aeskey [varchar](64) ,  
@wx_appsecret [varchar](64)   
AS  
BEGIN  
 SET NOCOUNT ON;  
 if @wx_id!=0
 begin
     update [ebs_kernel].[dbo].pub_weixin set  
    --cmp_fullname=case when @cmp_fullname='_none_' then cmp_fullname else @cmp_fullname end ,  
    [wx_code]= case when @wx_code='_none_' then [wx_code]  else @wx_code end,  
    [wx_type]= case when @wx_type='_none_' then [wx_type]  else @wx_type end,  
    [wx_title]= case when @wx_title='_none_' then [wx_title]  else @wx_title end,  
    [wx_appid]= case when @wx_appid=-999999999 then [wx_appid]  else @wx_appid end,  
    [wx_token]= case when @wx_token='_none_' then [wx_token]  else @wx_token end,  
    [wx_aeskey]= case when @wx_aeskey='_none_' then [wx_aeskey]  else @wx_aeskey end,  
    [wx_appsecret]= case when @wx_appsecret='_none_' then [wx_appsecret]  else @wx_appsecret end  
    where wx_id = @wx_id
end else
begin
    insert into ebs_kernel.dbo.pub_weixin(wx_cmpid,wx_title,wx_type,wx_code,wx_appsecret) 
    values(@wx_cmpid,@wx_title,@wx_type,@wx_code,@wx_appsecret)
end
END