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
1 4172
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
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...
|
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?
|
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
|
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
|
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?
| |
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...
|
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...
|
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?
|
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...
|
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...
|
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...
| |
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. ...
|
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...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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...
| |