Connecting Tech Pros Worldwide Help | Site Map

Executing Oracle Stored Procedures with IN OUT type parameter.

debasisdas's Avatar
Moderator
 
Join Date: Dec 2006
Location: Bangalore ,India
Posts: 7,505
#1   Sep 8 '07
Oracle Procedure with IN OUT type as parameter mode.
========================================
Expand|Select|Wrap|Line Numbers
  1. create or replace procedure inout(num in out number)
  2. as
  3. begin
  4. select (sal+nvl(comm,0))*12  into num from emp where empno=num;
  5. 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 PR As New ADODB.Parameter
  4. Dim PR1 As New ADODB.Parameter
  5.  
  6. Private Sub Command1_Click()
  7. CON.Open "Provider=MSDAORA.1;Password=DEBASIS;User ID=DEBASIS;Data Source=DAS;Persist Security Info=True"
  8. Dim CMD As New ADODB.Command
  9. CMD.ActiveConnection = CON
  10. CMD.CommandType = adCmdStoredProc
  11. CMD.CommandText = "inout"
  12. Set PR = CMD.CreateParameter("num", adNumeric, adParamInputOutput, 4, Int(DC1.Text))
  13. CMD.Parameters.Append PR
  14. CMD.Execute
  15. If Not IsNull(CMD.Parameters("num").Value) Then
  16. Text1.Text = CMD.Parameters("num").Value
  17. Else
  18. Text1.Text = ""
  19. MsgBox "Data Is Not Available"
  20. End If
  21. CMD.Cancel
  22. CON.Close
  23. End Sub



Closed Thread