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
1 4162
Sample code with IN & OUT parameters in a oracle procedure
-------------------------------------------------------------------------------------------- - CREATE OR REPLACE PROCEDURE IN_OUT
-
(
-
ENO IN EMP.EMPNO%TYPE,
-
V_NAME OUT EMP.ENAME%TYPE,
-
V_SAL OUT EMP.SAL%TYPE,
-
V_JOB OUT EMP.JOB%TYPE,
-
V_DEPTNO OUT EMP.DEPTNO%TYPE
-
)
-
IS
-
BEGIN
-
SELECT ENAME,SAL,JOB,DEPTNO INTO V_NAME,V_SAL,V_JOB,V_DEPTNO FROM EMP WHERE EMPNO=ENO;
-
EXCEPTION
-
WHEN NO_DATA_FOUND THEN
-
RAISE_APPLICATION_ERROR(-20005,'NO RECORD FOUND......!');
-
WHEN OTHERS THEN
-
RAISE_APPLICATION_ERROR(-20006,'SOME OTHER ERROR ......!');
-
END;
sample code to call the above procedure from vb6.0
----------------------------------------------------------------------------- - Dim CON As New ADODB.Connection
-
Dim RS As New ADODB.Recordset
-
Dim PR As New ADODB.Parameter
-
Dim PR1 As New ADODB.Parameter
-
Dim PR2 As New ADODB.Parameter
-
Dim PR3 As New ADODB.Parameter
-
Dim PR4 As New ADODB.Parameter
-
-
Private Sub Command1_Click()
-
On Error GoTo MYERR
-
CON.Open "Provider=MSDAORA.1;Password=TIGER;User ID=SCOTT;Data Source=ORCL;Persist Security Info=True"
-
Dim CMD As New ADODB.Command
-
CMD.ActiveConnection = CON
-
CMD.CommandType = adCmdStoredProc
-
CMD.CommandText = "IN_OUT"
-
Set PR = CMD.CreateParameter("ENO", adInteger, adParamInput, 4, Int(DC1.Text))
-
CMD.Parameters.Append PR
-
Set PR1 = CMD.CreateParameter("V_NAME", adVarChar, adParamOutput, 10)
-
CMD.Parameters.Append PR1
-
Set PR2 = CMD.CreateParameter("V_SAL", adNumeric, adParamOutput, 6)
-
CMD.Parameters.Append PR2
-
Set PR3 = CMD.CreateParameter("V_JOB", adVarChar, adParamOutput, 9)
-
CMD.Parameters.Append PR3
-
Set PR4 = CMD.CreateParameter("V_DEPTNO", adNumeric, adParamOutput, 2)
-
CMD.Parameters.Append PR4
-
CMD.Execute
-
Text1.Text = IIf(Not IsNull(CMD.Parameters("V_NAME").Value), CMD.Parameters("V_NAME").Value, "")
-
Text3.Text = IIf(Not IsNull(CMD.Parameters("V_SAL").Value), CMD.Parameters("V_SAL").Value, "")
-
Text2.Text = IIf(Not IsNull(CMD.Parameters("V_JOB").Value), CMD.Parameters("V_JOB").Value, "")
-
Text4.Text = IIf(Not IsNull(CMD.Parameters("V_DEPTNO").Value), CMD.Parameters("V_DEPTNO").Value, "")
-
CMD.Cancel
-
CON.Close
-
Exit Sub
-
MYERR:
-
MsgBox Err.Description
-
I = Val(Mid(Err.Description, 4, 6))
-
If I = -20005 Then
-
MsgBox "NO RECORD FOUND FOR THIS NO......!", vbCritical, "NO DATA"
-
ElseIf I = -20006 Then
-
MsgBox "SOME OTHER ERROR......!", vbCritical, "ERROR"
-
End If
-
End Sub
-
-
Private Sub Command2_Click()
-
Set CON = Nothing
-
End
-
End Sub
Check the above sample and change your code accordingly.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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?
...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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...
|
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...
| |