SQL Server Stored Procedure Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

SQL Server
Stored Procedure Examples

Quick Start
Encryption
File Access
IMAP
POP3
SMTP
Email Object
DKIM / DomainKey
FTP
HTML Conversion
HTTP
MHT
MIME
NTLM
RSA
Diffie-Hellman
DSA
Socket
Spider
SSH Key
SSH
SSH Tunnel
SFTP
String
Tar
Upload
XML
XMP
Zip

Amazon S3
Bz2
CSV
FileAccess
Byte Array
RSS
Atom
Self-Extractor

UU Encoding and Decoding

Demonstrates how to UU encode and decode.

Download Chilkat Crypt ActiveX

CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @sTmp0 nvarchar(4000)
    DECLARE @crypt int
    EXEC @hr = sp_OACreate 'Chilkat.Crypt2', @crypt OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    --  Any string argument automatically begins the 30-day trial.
    DECLARE @success int

    EXEC sp_OAMethod @crypt, 'UnlockComponent', @success OUT, '30-day trial'
    IF @success <> 1
      BEGIN
        EXEC sp_OAGetProperty @crypt, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        RETURN
      END

    DECLARE @s1 nvarchar(4000)

    DECLARE @s2 nvarchar(4000)

    DECLARE @s3 nvarchar(4000)

    SELECT @s1 = 'This string is to be UU encoded'

    EXEC sp_OASetProperty @crypt, 'UuMode', '666'
    EXEC sp_OASetProperty @crypt, 'UuFilename', 'something.txt'

    --  UU encode:
    EXEC sp_OAMethod @crypt, 'EncodeString', @s2 OUT, @s1, 'ansi', 'uu'

    --  Note: Call crypt.Encode instead of crypt.EncodeString
    --  to UU encode binary bytes (i.e. non-text binary data).


    PRINT @s2

    --  UU decode:
    DECLARE @crypt2 int
    EXEC @hr = sp_OACreate 'Chilkat.Crypt2', @crypt2 OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    EXEC sp_OAMethod @crypt2, 'DecodeString', @s3 OUT, @s2, 'ansi', 'uu'

    --  Note: Likewise, call crypt.Decode to decode non-text binary data.


    PRINT @s3

    --  Show the file permissions mode and filename found
    --  in the UU encoded data:

    EXEC sp_OAGetProperty @crypt2, 'UuMode', @sTmp0 OUT

    PRINT 'UuMode = ' + @sTmp0

    EXEC sp_OAGetProperty @crypt2, 'UuFilename', @sTmp0 OUT

    PRINT 'UuFilename = ' + @sTmp0

END
GO

 

© 2000-2010 Chilkat Software, Inc. All Rights Reserved.