(SQL Server) Example: Http.DownloadHash method
Demonstrates the DownloadHash method.
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @iTmp0 int
-- Important: Do not use nvarchar(max). See the warning about using nvarchar(max).
DECLARE @sTmp0 nvarchar(4000)
DECLARE @http int
EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
DECLARE @url nvarchar(4000)
SELECT @url = 'https://chilkatdownload.com/11.1.0/chilkat2-python-3.13-x64.zip'
DECLARE @encodedHash nvarchar(4000)
EXEC sp_OAMethod @http, 'DownloadHash', @encodedHash OUT, @url, 'sha256', 'hex_lower'
EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
IF @iTmp0 = 0
BEGIN
EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @http
RETURN
END
-- Expected value: 32583182374888c7761e7c15b998fd1d326c439c704d59380d34599f4be9b63a
PRINT 'sha256 = ' + @encodedHash
EXEC @hr = sp_OADestroy @http
END
GO
|