Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ORA-06513 Error Number - Why?

Status
Not open for further replies.

Creepers

Programmer
Nov 11, 2002
116
US
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

 
Forgot to mention. The goal is to great a cursur in Oracle and pass it into VB (ADO) as a recordset. The below code works fine when there are only two records in the cursor. It fails when there are 23 records. I do not know what happens between 2 and 23 records.

Thanks Again...
 
Looks like the problem is with EMPLOYEE_NUMBER field. In the DB the type is VARCHAR2 (that I suggest), while you are assigning it to the numerical variable. For two records it converted fine, but somewhere after that non-numeric EMPLOYEE_NUMBER happened. So either make the variable to be character, or run the query independently to see what is the problem with the data, if they are supposed to have only digits.
 
Thanks for the reply.... However I have figured out the problem. Look at line:
QSQL_ls = "{call rot_user_info.Get_User_RecordSet(?,?,?,?,{resultset 9, v_EmpNo, v_EmpFullName})}"

Changed the resultset number to 100 and it works. Ugly because one should know how many records are coming back before quering.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top