473,396 Members | 1,995 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Ado And Oracle Stored Procedure Problem Plzz Helpppp

1
hi All,
Iam new in oracle stored procedure, i have one stored procedure and it has to be accessed from vb6. my stored procedure as follows

-- employee salary will be entered by the user and itshould show employees less than the the given salary

CREATE OR REPLACE PROCEDURE employee1(empcode OUT VARCHAR2,
empname OUT VARCHAR2, POSITION OUT VARCHAR2, sal IN NUMBER) IS

CURSOR c1 IS SELECT empid, empname, grade FROM empmst
WHERE basicsal < sal;

BEGIN
OPEN c1;
LOOP
FETCH c1
INTO empcode, empname, POSITION;
EXIT
WHEN c1 % NOTFOUND;
END LOOP;

-- my vbcode is the following
Set db = New ADODB.Connection
db.CursorLocation = adUseClient
Set prempcode = New ADODB.Parameter
Set prempname = New ADODB.Parameter
Set prbasicsal = New ADODB.Parameter
Set prposition = New ADODB.Parameter
Set rsempmst = New ADODB.Recordset
rsempmst.CursorType = adOpenStatic

DBDriver = "Provider=MSDAORA.1;Password=ttt;User ID=ttt;Persist Security Info=True"

db.Open DBDriver

Set cm = New ADODB.Command
With cm
.ActiveConnection = db
.CommandType = adCmdStoredProc
.CommandText = "employee1" 'Name of the ORACLE Function, in String
.CommandTimeout = 10
End With
cm.CommandText = "employee1"

cm.Parameters.Append cm.CreateParameter("empcode", adVarChar, adParamOutput, 200)

cm.Parameters.Append cm.CreateParameter("empname", adVarChar, adParamOutput, 200)

cm.Parameters.Append cm.CreateParameter("position", adVarChar, adParamOutput, 200)


cm.Parameters.Append cm.CreateParameter("basicsal1", adNumeric, adParamInput, , Val(Text1.Text))


Set rsempmst.Source = cm.Execute
rsempmst.Open
Do Until rsempmst.EOF
MsgBox (rsempmst("empid"))
rsempmst.MoveNext
Loop

' this code showing error that
Run time error 3001
Arguments are wrong type are acceptable range, or are inconflict with
one another

Plz helppppppppppp
Thanks
Aug 5 '07 #1
1 4162
debasisdas
8,127 Expert 4TB
Sample code with IN & OUT parameters in a oracle procedure
--------------------------------------------------------------------------------------------
Expand|Select|Wrap|Line Numbers
  1. CREATE OR REPLACE PROCEDURE IN_OUT
  2. (
  3. ENO IN EMP.EMPNO%TYPE,
  4. V_NAME OUT EMP.ENAME%TYPE,
  5. V_SAL  OUT EMP.SAL%TYPE,
  6. V_JOB OUT EMP.JOB%TYPE,
  7. V_DEPTNO OUT EMP.DEPTNO%TYPE
  8. )
  9. IS
  10. BEGIN
  11. SELECT ENAME,SAL,JOB,DEPTNO INTO V_NAME,V_SAL,V_JOB,V_DEPTNO FROM EMP WHERE EMPNO=ENO;
  12. EXCEPTION
  13. WHEN NO_DATA_FOUND THEN
  14. RAISE_APPLICATION_ERROR(-20005,'NO RECORD FOUND......!');
  15. WHEN OTHERS THEN
  16. RAISE_APPLICATION_ERROR(-20006,'SOME OTHER ERROR ......!');
  17. END;
sample code to call the above procedure from vb6.0
-----------------------------------------------------------------------------
Expand|Select|Wrap|Line Numbers
  1. Dim CON As New ADODB.Connection
  2. Dim RS As New ADODB.Recordset
  3. Dim PR As New ADODB.Parameter
  4. Dim PR1 As New ADODB.Parameter
  5. Dim PR2 As New ADODB.Parameter
  6. Dim PR3 As New ADODB.Parameter
  7. Dim PR4 As New ADODB.Parameter
  8.  
  9. Private Sub Command1_Click()
  10. On Error GoTo MYERR
  11. CON.Open "Provider=MSDAORA.1;Password=TIGER;User ID=SCOTT;Data Source=ORCL;Persist Security Info=True"
  12. Dim CMD As New ADODB.Command
  13. CMD.ActiveConnection = CON
  14. CMD.CommandType = adCmdStoredProc
  15. CMD.CommandText = "IN_OUT"
  16. Set PR = CMD.CreateParameter("ENO", adInteger, adParamInput, 4, Int(DC1.Text))
  17. CMD.Parameters.Append PR
  18. Set PR1 = CMD.CreateParameter("V_NAME", adVarChar, adParamOutput, 10)
  19. CMD.Parameters.Append PR1
  20. Set PR2 = CMD.CreateParameter("V_SAL", adNumeric, adParamOutput, 6)
  21. CMD.Parameters.Append PR2
  22. Set PR3 = CMD.CreateParameter("V_JOB", adVarChar, adParamOutput, 9)
  23. CMD.Parameters.Append PR3
  24. Set PR4 = CMD.CreateParameter("V_DEPTNO", adNumeric, adParamOutput, 2)
  25. CMD.Parameters.Append PR4
  26. CMD.Execute
  27. Text1.Text = IIf(Not IsNull(CMD.Parameters("V_NAME").Value), CMD.Parameters("V_NAME").Value, "")
  28. Text3.Text = IIf(Not IsNull(CMD.Parameters("V_SAL").Value), CMD.Parameters("V_SAL").Value, "")
  29. Text2.Text = IIf(Not IsNull(CMD.Parameters("V_JOB").Value), CMD.Parameters("V_JOB").Value, "")
  30. Text4.Text = IIf(Not IsNull(CMD.Parameters("V_DEPTNO").Value), CMD.Parameters("V_DEPTNO").Value, "")
  31. CMD.Cancel
  32. CON.Close
  33. Exit Sub
  34. MYERR:
  35. MsgBox Err.Description
  36. I = Val(Mid(Err.Description, 4, 6))
  37. If I = -20005 Then
  38. MsgBox "NO RECORD FOUND FOR THIS NO......!", vbCritical, "NO DATA"
  39. ElseIf I = -20006 Then
  40. MsgBox "SOME OTHER ERROR......!", vbCritical, "ERROR"
  41. End If
  42. End Sub
  43.  
  44. Private Sub Command2_Click()
  45. Set CON = Nothing
  46. End
  47. End Sub
Check the above sample and change your code accordingly.
Aug 6 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: kristoff plasun | last post by:
I have a problem with a C++ DCOM application that prints Crystal Reports with data from Oracle. The SQL query is relatively complex but when the report is printed from the Crystal Reports...
0
by: Chan | last post by:
Hi, I am trying to send set of rows from my c# web service to Oracle stored procedure. I think I can get this done using OpenXML in SQL Server. How to implement this in Oracle Stored...
1
by: robin via SQLMonster.com | last post by:
I've tried several different way to execute a oracle stored procedure from a DTS package but to no avail. I have a Linked Server setup which does bring back Oracle tables from the server when I...
0
by: totierne | last post by:
comp.databases.ms-access, I want to know how to use Oracle views with session variables in Access. The parameterised views in access, are migrated to views with per session variables. The...
0
by: Chan | last post by:
Hi, I am trying to send set of rows from my c# web service to Oracle stored procedure. I think I can get this done using OpenXML in SQL Server. How to implement this in Oracle Stored...
1
by: Chad | last post by:
Hi, I am a SQL Server programmer using Oracle for the first time. In our .NET client apps which use a SQL Server back end, we would use Stored Procedure exclusively for all database access for...
0
by: Tom | last post by:
Looking for some help with stored procedure call issues. Conceptually, I need to pass a data structure as the sole parameter to the Oracle stored procedure. Sounds simple enough....but how? ...
14
by: jehugaleahsa | last post by:
Hello: I am working with Oracle .NET Stored Procedures. I would like to know how to return the results of a SELECT statement. I have tried returning a OracleRefCursor and a DataTable, but...
23
by: Gloops | last post by:
Hello everybody, Is anyone able to give me some indications about how to develop an Access interface for an Oracle database ? I dispose of Access 2003 (11.6566.8107) SP2, Oracle 9i 9.2.0.1.0...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.