473,427 Members | 1,792 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,427 developers and data experts.

Executing Oracle Stored Procedures with IN Type Parameter.

debasisdas
8,127 Expert 4TB
This thread contains some of the sample code showing the method of executing Oracle stored procedures and functions from VB .

Hope the user finds them useful.

Oracle Procedure with only IN type as parameter mode.
========================================
Expand|Select|Wrap|Line Numbers
  1. CREATE OR REPLACE PROCEDURE DEPTINS
  2. (
  3. DNO DEPT.DEPTNO%TYPE,
  4. DN DEPT.DNAME%TYPE,
  5. LC DEPT.LOC%TYPE
  6. )
  7. AUTHID CURRENT_USER
  8. IS
  9. BEGIN
  10. INSERT INTO DEPT VALUES(DNO,DN,LC);
  11. DBMS_OUTPUT.PUT_LINE('ONE ROW INSERTED......!');
  12. EXCEPTION
  13. WHEN DUP_VAL_ON_INDEX THEN
  14. RAISE_APPLICATION_ERROR(-20002,'DUPLICATE VALUE......!');
  15. WHEN OTHERS THEN
  16. RAISE_APPLICATION_ERROR(-20001,'SOME OTHER ERROR ......!');
  17. END;
To call the above Oracle procedure from Vb.
================================
Expand|Select|Wrap|Line Numbers
  1. 'general declaration
  2. Dim CON As New ADODB.Connection
  3. Dim RS As New ADODB.Recordset
  4. Dim PR As New ADODB.Parameter
  5. Dim PR1 As New ADODB.Parameter
  6. Dim PR2 As New ADODB.Parameter
  7. Dim CMD As New ADODB.Command
  8.  
  9. Private Sub Command1_Click()
  10. On Error GoTo MYERR
  11. CON.Open "Provider=MSDAORA.1;Password=DEBASIS;User ID=DEBASIS;Data Source=DAS;Persist Security Info=True"
  12. CMD.ActiveConnection = CON
  13. CMD.CommandType = adCmdStoredProc
  14. CMD.CommandText = "DEPTINS"
  15. Set PR = CMD.CreateParameter("DNO", adNumeric, adParamInput, 2, Val(T1.Text))
  16. CMD.Parameters.Append PR
  17. Set PR1 = CMD.CreateParameter("DN", adVarChar, adParamInput, 14, Trim(T2.Text))
  18. CMD.Parameters.Append PR1
  19. Set PR2 = CMD.CreateParameter("LC", adVarChar, adParamInput, 13, Trim(T3.Text))
  20. CMD.Parameters.Append PR2
  21. CMD.Execute
  22. CON.Close
  23. Exit Sub
  24. MYERR:
  25. I = Val(Mid(Err.Description, 4, 6))
  26. If I = -20002 Then
  27. MsgBox "DUPLICATE ENTRY"
  28. ElseIf I = -20001 Then
  29. MsgBox "SOME OTHER ERROR"
  30. End If
  31. End Sub
Also check
Stored Procedures with both IN & OUT type parameter.
Sep 8 '07 #1
0 5842

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

Similar topics

1
by: Mohammad | last post by:
hi when i try to send a blob or Longraw value with more than 32k as parameter to stored procedure in oracle 9i, the following exception raise "ORA-01460 : Unimplemented or Unreasonable...
11
by: jrefactors | last post by:
I want to know the differences between SQL Server 2000 stored procedures and oracle stored procedures? Do they have different syntax? The concept should be the same that the stored procedures...
4
by: Rhino | last post by:
Is it possible for a Java Stored Procedure in DB2 V7.2 (Windows) to pass a Throwable back to the calling program as an OUT parameter? If yes, what datatype should I use when registering the...
3
by: IGotYourDotNet | last post by:
Can anyone point me to some example ASP.NET apps that use Oracle has a backend and C# as the language? I need to figure out how to populate a drop down, and then a datagrid depending on what the...
4
by: Stuart Ferguson | last post by:
I am currently writing code to execute SQL Server 2000 Stored procedured using the ODBC.NET SQL Server Driver. The particular stored procedure I am using has multiple paramaters which I have...
1
by: A1 Ronen | last post by:
Hi all I got problem regarding executing all stored procedure through common procedures where we have different parameter with different names, type and data type The Function is as follows...
0
by: george | last post by:
Hi world! Anyone experienced building gridview in Oracle environment using stored procedures, please help! Right now, I have issues using Oracle SP, I spent a whole day on this and still...
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...
4
by: --CELKO-- | last post by:
I need to convert a bunch of DB2 triggers to Oracle. Is there any kind of tools for this?
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
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...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.