Sample code for 30+ languages & platforms
SQL Server

Transition from Http.S3_DeleteMultipleObjects to Http.S3_DeleteObjects

Provides instructions for replacing deprecated S3_DeleteMultipleObjects method calls with S3_DeleteObjects.

Chilkat SQL Server Downloads

SQL Server
-- 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 @success int
    SELECT @success = 0

    DECLARE @http int
    EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    DECLARE @bucketName nvarchar(4000)
    SELECT @bucketName = 'testBucket'

    DECLARE @sa int
    EXEC @hr = sp_OACreate 'Chilkat.StringArray', @sa OUT

    EXEC sp_OAMethod @sa, 'Append', @success OUT, 'starfish.jpg'
    EXEC sp_OAMethod @sa, 'Append', @success OUT, 'clam.jpg'
    EXEC sp_OAMethod @sa, 'Append', @success OUT, 'shark.jpg'

    DECLARE @st int
    EXEC @hr = sp_OACreate 'Chilkat.StringTable', @st OUT

    EXEC sp_OAMethod @st, 'Append', @success OUT, 'starfish.jpg'
    EXEC sp_OAMethod @st, 'Append', @success OUT, 'clam.jpg'
    EXEC sp_OAMethod @st, 'Append', @success OUT, 'shark.jpg'

    -- ------------------------------------------------------------------------
    -- The S3_DeleteMultipleObjects method is deprecated:

    DECLARE @responseObj int
    EXEC sp_OAMethod @http, 'S3_DeleteMultipleObjects', @responseObj OUT, @bucketName, @sa
    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
        EXEC @hr = sp_OADestroy @sa
        EXEC @hr = sp_OADestroy @st
        RETURN
      END

    -- ...
    -- ...

    EXEC @hr = sp_OADestroy @responseObj

    -- ------------------------------------------------------------------------
    -- Do the equivalent using S3_DeleteObjects.
    -- Your application creates a new, empty HttpResponse object which is passed 
    -- in the last argument and filled upon success.

    DECLARE @responseOut int
    EXEC @hr = sp_OACreate 'Chilkat.HttpResponse', @responseOut OUT

    EXEC sp_OAMethod @http, 'S3_DeleteObjects', @success OUT, @bucketName, @st, @responseOut
    IF @success = 0
      BEGIN
        EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @sa
        EXEC @hr = sp_OADestroy @st
        EXEC @hr = sp_OADestroy @responseOut
        RETURN
      END

    EXEC @hr = sp_OADestroy @http
    EXEC @hr = sp_OADestroy @sa
    EXEC @hr = sp_OADestroy @st
    EXEC @hr = sp_OADestroy @responseOut


END
GO