Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 com object and return value

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-09-28 : 09:07:42
Gunter writes "Hi all,

We are currently working on a project(SQL Server 2000) in which we should integrate a COM object for file encryption/decryption in a stored procedure. The following source code is working, but we don´t know how to insert the content of the variable @ClearFileOut in a temporary table. The return value is only a single numeric value but we would need a string. Is it possible to define something like a global variable or do you know is there a possibility to work around to get a return value (string) from a stored procedure?


The source:

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON
GO


CREATE PROCEDURE AsymDecryptFile
@PrivateKey varchar(255) = '',
@CipherFile varchar(255) = '',
@ClearDir varchar(255)='',
@HashCheck int
AS

DECLARE @object int
DECLARE @hr int
DECLARE @ClearFileOut varchar(255)
DECLARE @source varchar(255)
DECLARE @description varchar(255)
DECLARE @Tmp varchar(255)

--- Create a DynCrypto object
EXEC @hr = sp_OACreate 'DynCrypto.Crypto', @object OUT
IF @hr <> 0
BEGIN
--- Report error
EXEC @hr = sp_OAGetErrorInfo @object, @source OUT, @description OUT
IF @hr = 0
BEGIN
SELECT @Tmp = '(' + @source + ') ' + @description
PRINT 'F1:'+@Tmp
END
RETURN
END

--- Call AsymDecrypt
EXEC @hr = sp_OAGetProperty @object,'AsymDecryptFile', @ClearFileOut OUT,@PrivateKey,@CipherFile,@ClearDir,@HashCheck
IF @hr <> 0
BEGIN
--- Report error
EXEC @hr = sp_OAGetErrorInfo @object, @source OUT, @description OUT
IF @hr = 0
BEGIN
SELECT @Tmp = '(' + @source + ') ' + @description
PRINT 'f2:'+@Tmp
END
RETURN
END
return


GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO


Thank you very much in advance
best regards
gunter"
   

- Advertisement -