473,569 Members | 2,648 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Ado And Oracle Stored Procedure Problem Plzz Helpppp

1 New Member
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(empco de 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.Connectio n
db.CursorLocati on = 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.Cursor Type = adOpenStatic

DBDriver = "Provider=MSDAO RA.1;Password=t tt;User ID=ttt;Persist Security Info=True"

db.Open DBDriver

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

cm.Parameters.A ppend cm.CreateParame ter("empcode", adVarChar, adParamOutput, 200)

cm.Parameters.A ppend cm.CreateParame ter("empname", adVarChar, adParamOutput, 200)

cm.Parameters.A ppend cm.CreateParame ter("position", adVarChar, adParamOutput, 200)


cm.Parameters.A ppend cm.CreateParame ter("basicsal1" , adNumeric, adParamInput, , Val(Text1.Text) )


Set rsempmst.Source = cm.Execute
rsempmst.Open
Do Until rsempmst.EOF
MsgBox (rsempmst("empi d"))
rsempmst.MoveNe xt
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 4172
debasisdas
8,127 Recognized Expert Expert
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
15131
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 designer it shows up very fast. When the report is printed from my application it takes about ten times as long to get the report to appear. When...
0
2504
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 Procedure? Can I pass a table or cursor or XML to Oracle stored procedure?
1
12204
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 click on the Tables icon. Here's my DTS statement: exec omsd..OMS_TECO.SP_Callback_Update_Pkg(116); omsd is the linked server
0
3015
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 open questions: How to display a resultset
0
1913
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 Procedure? Can I pass a table or cursor or XML to Oracle stored procedure?
1
4351
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 increased security as well as the pre-compiled advantage. To minimize trips to the db server, we would often call SPs that return more than one...
0
2200
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? First, looking at this from the stored procedure side, I see a few things the procedure can do: 1) receive a CLOB/BLOB 2) receive a user defined...
14
4575
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 nothing seems to work. What data type must I return for this to be accepted as .NET stored procedure?
23
3375
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 and ODBC 3.525.1117.0, on Windows XP Pro 5.1.2600 SP2 Nu 2600. I failed executing an Oracle stored procedure from Access, and a trigger to store...
0
7701
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7615
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7924
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7677
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7979
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3643
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
940
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.