Below is a Oracle Procedure that creates a cursur:
PROCEDURE Get_User_RecordSet(n_AppID IN Number, v_OrgID IN VarChar2, n_PriorityValue IN Number, v_Message OUT Varchar2, v_EmpNo OUT t_EmpNo, v_EmpFullName OUT t_EmpFullName)
IS
Cursor Emp_Cursor IS
SELECT EMPLOYEE_NUMBER, FULL_NAME
FROM XXROT.ROT_CSTM_APP_USERS_W_LKUPS_V
WHERE CUSTOM_APP_ID = n_AppID AND
ORG_ID = v_OrgID AND
USER_GROUP_PRIORITY_VALUE = n_PriorityValue
ORDER BY FULL_NAME;
percount NUMBER DEFAULT 1;
BEGIN
v_Message := Null;
FOR Record_lv IN Emp_Cursor
LOOP
v_EmpNo(percount) := Record_lv.Employee_Number;
v_EmpFullName(percount) := Record_lv.Full_Name;
percount := percount + 1;
END LOOP;
Exception
When No_Data_Found Then
Null;
When Others Then
v_Message := 'Error Code: ' || SQLCODE || ' Error Descr:'||SQLERRM;
END Get_User_RecordSet;
******************************************
Below is the VB code that calls the above procedure:
Public Function Initialize() As Boolean
Dim StoredProcedure_cnn As ADODB.Connection
Dim StoredProcedure_cmd As ADODB.Command
Dim StoredProcedure_rs As ADODB.Recordset
Dim ConnectionString_ls As String
Dim QSQL_ls As String
On Error GoTo InitializeErrHandler
Screen.MousePointer = vbHourglass
DoEvents
ConnectionString_ls="UID=XXROT;PWD=XXROT;driver={Microsoft ODBC for Oracle};SERVER=" & gsOracleInstance & ";"
Set StoredProcedure_cnn = New ADODB.Connection
With StoredProcedure_cnn
.ConnectionString = ConnectionString_ls
.CursorLocation = adUseClient
.Open
End With
QSQL_ls = "{call rot_user_info.Get_User_RecordSet(?,?,?,?,{resultset 9, v_EmpNo, v_EmpFullName})}"
Set StoredProcedure_cmd = New ADODB.Command
With StoredProcedure_cmd
Set .ActiveConnection = StoredProcedure_cnn
.CommandText = QSQL_ls
.CommandType = adCmdText
.Parameters.Append .CreateParameter("n_AppID", adInteger, adParamInput)
.Parameters.Append .CreateParameter("v_OrgID", adChar, adParamInput, 3)
.Parameters.Append .CreateParameter("n_PriorityValue", adInteger, adParamInput)
.Parameters.Append .CreateParameter("v_Message", adChar, adParamOutput, 255)
End With
Set StoredProcedure_rs = New ADODB.Recordset
With StoredProcedure_rs
.CursorType = adOpenStatic
.LockType = adLockReadOnly
End With
Set StoredProcedure_rs.Source = StoredProcedure_cmd
StoredProcedure_cmd(0) = 4 ' Application ID, 4 = WIP Mover
StoredProcedure_cmd(1) = gsSiteOrgCode
StoredProcedure_cmd(2) = 250 ' User Priority Value, 250 = Finisher
StoredProcedure_rs.Open 'WHERE THE ERROR OCCURS
Do While Not StoredProcedure_rs.EOF
'Debug.Print StoredProcedure_rs.Fields(0) & ": " & StoredProcedure_rs.Fields(1)
lstFinishers.AddItem StoredProcedure_rs.Fields(0) & ": " & StoredProcedure_rs.Fields(1)
StoredProcedure_rs.MoveNext
Loop
StoredProcedure_rs.Close
Initialize = True
InitializeExitPoint:
On Error Resume Next
StoredProcedure_cnn.Close
Set StoredProcedure_cnn = Nothing
Set StoredProcedure_cmd = Nothing
Set StoredProcedure_rs = Nothing
Screen.MousePointer = vbDefault
Exit Function
Any Help would be appreciated
PROCEDURE Get_User_RecordSet(n_AppID IN Number, v_OrgID IN VarChar2, n_PriorityValue IN Number, v_Message OUT Varchar2, v_EmpNo OUT t_EmpNo, v_EmpFullName OUT t_EmpFullName)
IS
Cursor Emp_Cursor IS
SELECT EMPLOYEE_NUMBER, FULL_NAME
FROM XXROT.ROT_CSTM_APP_USERS_W_LKUPS_V
WHERE CUSTOM_APP_ID = n_AppID AND
ORG_ID = v_OrgID AND
USER_GROUP_PRIORITY_VALUE = n_PriorityValue
ORDER BY FULL_NAME;
percount NUMBER DEFAULT 1;
BEGIN
v_Message := Null;
FOR Record_lv IN Emp_Cursor
LOOP
v_EmpNo(percount) := Record_lv.Employee_Number;
v_EmpFullName(percount) := Record_lv.Full_Name;
percount := percount + 1;
END LOOP;
Exception
When No_Data_Found Then
Null;
When Others Then
v_Message := 'Error Code: ' || SQLCODE || ' Error Descr:'||SQLERRM;
END Get_User_RecordSet;
******************************************
Below is the VB code that calls the above procedure:
Public Function Initialize() As Boolean
Dim StoredProcedure_cnn As ADODB.Connection
Dim StoredProcedure_cmd As ADODB.Command
Dim StoredProcedure_rs As ADODB.Recordset
Dim ConnectionString_ls As String
Dim QSQL_ls As String
On Error GoTo InitializeErrHandler
Screen.MousePointer = vbHourglass
DoEvents
ConnectionString_ls="UID=XXROT;PWD=XXROT;driver={Microsoft ODBC for Oracle};SERVER=" & gsOracleInstance & ";"
Set StoredProcedure_cnn = New ADODB.Connection
With StoredProcedure_cnn
.ConnectionString = ConnectionString_ls
.CursorLocation = adUseClient
.Open
End With
QSQL_ls = "{call rot_user_info.Get_User_RecordSet(?,?,?,?,{resultset 9, v_EmpNo, v_EmpFullName})}"
Set StoredProcedure_cmd = New ADODB.Command
With StoredProcedure_cmd
Set .ActiveConnection = StoredProcedure_cnn
.CommandText = QSQL_ls
.CommandType = adCmdText
.Parameters.Append .CreateParameter("n_AppID", adInteger, adParamInput)
.Parameters.Append .CreateParameter("v_OrgID", adChar, adParamInput, 3)
.Parameters.Append .CreateParameter("n_PriorityValue", adInteger, adParamInput)
.Parameters.Append .CreateParameter("v_Message", adChar, adParamOutput, 255)
End With
Set StoredProcedure_rs = New ADODB.Recordset
With StoredProcedure_rs
.CursorType = adOpenStatic
.LockType = adLockReadOnly
End With
Set StoredProcedure_rs.Source = StoredProcedure_cmd
StoredProcedure_cmd(0) = 4 ' Application ID, 4 = WIP Mover
StoredProcedure_cmd(1) = gsSiteOrgCode
StoredProcedure_cmd(2) = 250 ' User Priority Value, 250 = Finisher
StoredProcedure_rs.Open 'WHERE THE ERROR OCCURS
Do While Not StoredProcedure_rs.EOF
'Debug.Print StoredProcedure_rs.Fields(0) & ": " & StoredProcedure_rs.Fields(1)
lstFinishers.AddItem StoredProcedure_rs.Fields(0) & ": " & StoredProcedure_rs.Fields(1)
StoredProcedure_rs.MoveNext
Loop
StoredProcedure_rs.Close
Initialize = True
InitializeExitPoint:
On Error Resume Next
StoredProcedure_cnn.Close
Set StoredProcedure_cnn = Nothing
Set StoredProcedure_cmd = Nothing
Set StoredProcedure_rs = Nothing
Screen.MousePointer = vbDefault
Exit Function
Any Help would be appreciated