Stored procedures 如何在LotusScript中接收DB2存储过程结果

Stored procedures 如何在LotusScript中接收DB2存储过程结果,stored-procedures,db2,lotus-notes,lotusscript,Stored Procedures,Db2,Lotus Notes,Lotusscript,我有以下DB2存储过程 CREATE PROCEDURE SCHEME.getData(IN inputParam VARCHAR(100), OUT outputParam VARCHAR(100)) BEGIN -- do sth SET outputParam = 'something2'; END 我希望使用on param运行此过程,并在LotusScript代理中接收结果: Set con = New ODBCConnection Set qry = New ODB

我有以下DB2存储过程

CREATE PROCEDURE SCHEME.getData(IN inputParam VARCHAR(100), OUT outputParam VARCHAR(100))
BEGIN
    -- do sth
    SET outputParam = 'something2';
END
我希望使用on param运行此过程,并在LotusScript代理中接收结果:

Set con = New ODBCConnection
Set qry = New ODBCQuery
Set result = New ODBCResultSet

Call con.ConnectTo("MyOdbcDriverName", "user", "pass")

Set result.Query = qry
Set qry.Connection = con


sql = |Call SCHEME.getData('arg1')|//it runs ok - no odbc errors

qry.Sql = sql
result.Execute

If result.Isresultsetavailable() Then    //false here so no idea how to process the result
    REM do sth with result
    value = result.GetValue(1)      
Else

我应该向SQL语句添加什么,以及如何处理结果以接收结果?

有一个方法
ODBCResultSet.ExecProcedure
,因此类似的方法可能会起作用:

Dim inputParm as String
Dim outputParm as String

Set inputParm = 'arg1'
result.ExecProcedure('SCHEME.GETDATA',inputParm,outputParm)

Print outputParm
请注意,您可能希望使用大写的过程名称


我发现以下解决方案适合我。它使用LCConnection类而不是ODBCConnection

Dim sess As New LCSession
Dim conn As New LCConnection ("db2")

'set the connection parameters...
conn.Database = "ODBCSourceName"
conn.UserId = "user"
conn.Password = "pass"

'connect to the database...
conn.Connect    

'set the stored procedure owner and stored procedure name...            
conn.Procedure = "SCHEME.getData"

'set Fieldnames property with any output parameters declared in 
'the stored procedure...
conn.Fieldnames = "outputParam" 'stored procedure output param name



'declare any fields and fieldlists for input/output data...

Dim inputParams As New LCFieldList
Dim outputParams As New LCFieldlist
Dim inputValue As LCField
Dim outputValue As LCField

Dim out As Double

'set the input parameters of the stored procedure...                
Set inputValue = inputParams.Append ("inputParam", LCTYPE_TEXT) 'stored procedure input param name                  
inputValue.Value = "my input value"                 


'with the input parameters set, call the stored procedure...
'the declared output_parms fieldlist will hold the output parameters 
'of the stored procedure...

out = conn.Call (inputParams, 1, outputParams)

'fetch parameter(s) into the output_parms fieldlist...
out = conn.Fetch (outputParams) 

'retrieve the parameter(s) from the output_parms fieldlist...
Set outputValue = outputParams.GetField (1)         

'do somethin with the result
Print outputValue.Value(0)  
更多信息:


此解决方案以“查询中缺少参数”错误结束。请参见编辑:在
ODBCResultSet
中有一个调用过程的特殊方法。您的解决方案现在也适用于我。它比我之前发现的要好一点,因为它不需要添加硬编码的参数名。