Question : Oracle REF CURSOR in Excel VBA

Hi Experts,
I have an Oracle package and a procedure defined that returns a REF CURSOR. I am able to run this procedure using PL/SQL but I want to use Excel VBA and get the data into an ADO recordset. When I do it I am getting "wrong number of arguments or argument types error" in excel VBA. I tried lot of things but in vain. I am pasting my procedure declaration and my Excel VBA code. Kindly provide your expertise as to how I can get the data into Excel VBA

Environment:
Excel 2003
Oracle 9i

Thank you very much for your time!
Regards
$wapnil
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
//ORACLE PROCEDURE//
PROCEDURE PRC_PATS_GETPORTVALUES(d_BenchMark IN DATE, d_EndDate IN DATE, s_Portfolios IN VARCHAR2, io_cursor OUT t_cursor)
IS
BEGIN
DECLARE
v_cursor t_cursor;
BEGIN
 
	    OPEN v_cursor FOR
		-- Get the Security Positions
		SELECT AS_OF_DATE, PORTFOLIO, MARKETVALUE, CASH, FUTURESGL, FUTURESCOMM FROM <>;
io_cursor := v_cursor;
END;
END PRC_PATS_GETPORTVALUES;
 
//ORACLE PACKAGE//
PACKAGE PKG_PATS_GETPORTFOLIOVALUES AS
	TYPE t_cursor IS REF CURSOR;
	PROCEDURE PRC_PATS_GETPORTVALUES (d_BenchMark IN DATE, d_EndDate IN DATE, s_Portfolios IN VARCHAR2, io_cursor OUT t_cursor);
END PKG_PATS_GETPORTFOLIOVALUES;
 
//EXCEL VBA CODE//
Set objCmd = New ADODB.Command
            objCmd.Parameters.Append objCmd.CreateParameter(Type:=adDate, Direction:=adParamInput, Value:=CDate(strFromDate))
            objCmd.Parameters.Append objCmd.CreateParameter(Type:=adDate, Direction:=adParamInput, Value:=CDate(strToDate))
            objCmd.Parameters.Append objCmd.CreateParameter(Type:=adVarChar, Direction:=adParamInput, Size:=9, Value:=strPMISAcc)
            objCmd.CommandType = adCmdText
            objCmd.CommandText = "{CALL PKG_PATS_GETPORTFOLIOVALUES.PRC_PATS_GETPORTVALUES(?,?,?)}"
'Get the Connection Information
    Set oConnection = OpenConnection(strConn)
     cmd.ActiveConnection = oConnection
    'Execute the Stored Procedure
    
    Set rst = New ADODB.Recordset
    rst.CursorLocation = adUseClient
    rst.CursorType = adOpenDynamic
    Set rst = cmd.Execute(lRowsAffected)
 
-- I am using the following connection string
Provider=OraOLEDB.Oracle;Data Source=;User Id=;Password=

Answer : Oracle REF CURSOR in Excel VBA

I can ignore the other pieces in the code in the first post.

But I can't really ignore the missing VBA code, if what you have is a VBA problem.

What would the call that works look like in PL/SQL?

As far as I can see t_cursor is a cursor variable that is declared with the cursor type v_cursor.

And as far as I can see that type represents a row in a table.

Random Solutions  
 
programming4us programming4us