网站链接: element-ui dtcms
当前位置: 首页 > 技术博文  > 技术博文

SQL调用存储过程执行http访问比如微信支付、钉钉审批等

2020/10/14 11:21:31 人评论

/ 开启Transact-SQL 批处理/sp_configure show advanced options, 1;GORECONFIGURE;GOsp_configure Ole Automation Procedures, 1;GORECONFIGURE;GOEXEC sp_configure Ole Automation Procedures;GO/1、建立表/CREATE TABLE [dbo].[wexinCall]([out_trade_no] varchar NU…

/ 开启Transact-SQL 批处理/
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'Ole Automation Procedures', 1;
GO
RECONFIGURE;
GO

EXEC sp_configure 'Ole Automation Procedures';
GO

/1、建立表/
CREATE TABLE [dbo].[wexinCall](
[out_trade_no] varchar NULL,
[total_fee] varchar NULL,
[device_info] varchar NULL,
[spbill_create_ip] varchar NULL,
[notify_url] varchar NULL,
[trade_type] varchar NULL,
[result_code] varchar NULL,
[payresult_code] varchar NULL,
[transaction_id] varchar NULL
) ON [PRIMARY]
--商户订单号 out_trade_no
--订单金额 total_fee
--设备号 device_info
--终端IP spbill_create_ip
--通知地址 notify_url
--交易类型 trade_type
--业务结果 result_code
--客户支付结果 payresult_code
--微信支付订单号 transaction_id
/2、存储过程/

CREATE PROCEDURE P_GET_HttpRequestInfo(

@URL varchar(500),

@status int=0 OUT,

@returnText varchar(2000)='' OUT

)

AS

BEGIN

DECLARE @object int,@errSrc int

/初始化对/

EXEC @status = SP_OACreate 'Msxml2.ServerXMLHTTP.3.0', @object OUT

IF @status <> 0

BEGIN

EXEC SP_OAGetErrorInfo @object, @errSrc OUT, @returnText OUT

RETURN

END

/创建链接/

EXEC @status= SP_OAMethod @object,'open',NULL,'GET',@URL

IF @status <> 0

BEGIN

EXEC SP_OAGetErrorInfo @object, @errSrc OUT, @returnText OUT

RETURN

END

EXEC @status=SP_OAMethod @object,'setRequestHeader','Content-Type','application/x-www-form-urlencoded'

/发起请求/

EXEC @status= SP_OAMethod @object,'send',NULL

IF @status <> 0

BEGIN

EXEC SP_OAGetErrorInfo @object, @errSrc OUT, @returnText OUT

RETURN

END

/获取返回/

EXEC @status= SP_OAGetProperty @object,'responseText',@returnText OUT

IF @status <> 0

BEGIN

EXEC SP_OAGetErrorInfo @object, @errSrc OUT, @returnText OUT

RETURN

END

END;

/3、调用HTTP/

DECLARE @returnText VARCHAR(500)

DECLARE @status int

DECLARE @urlStr VARCHAR(255)

SET @urlStr = 'http://xxxxxxxxx:811/wx2.aspx?pay=2';

EXEC P_GET_HttpRequestInfo @urlStr, @status OUTPUT, @returnText OUTPUT;
select SUBSTRING(@returnText,0,charindex('<',@returnText)); ---打印


相关资讯

    暂无相关的数据...

共有条评论 网友评论

验证码: 看不清楚?