(SQL Server) Replace Deprecated GetExpirationDt
Shows how to replace the deprecated GetExpirationDt method.
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
-- Important: Do not use nvarchar(max). See the warning about using nvarchar(max).
DECLARE @sTmp0 nvarchar(4000)
DECLARE @cache int
-- Use "Chilkat_9_5_0.Cache" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.Cache', @cache OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
-- ....
-- ....
DECLARE @cache_item_key nvarchar(4000)
SELECT @cache_item_key = 'xyz'
-- Instead of this:
DECLARE @dt1 int
EXEC sp_OAMethod @cache, 'GetExpirationDt', @dt1 OUT, @cache_item_key
EXEC @hr = sp_OADestroy @dt1
-- Do this:
DECLARE @dt2 int
-- Use "Chilkat_9_5_0.CkDateTime" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.CkDateTime', @dt2 OUT
DECLARE @success int
EXEC sp_OAMethod @cache, 'GetExpirationStr', @sTmp0 OUT, @cache_item_key
EXEC sp_OAMethod @dt2, 'SetFromRfc822', @success OUT, @sTmp0
EXEC @hr = sp_OADestroy @cache
EXEC @hr = sp_OADestroy @dt2
END
GO
|