CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2001
    Posts
    33

    Array from Oracle stored procedure

    I need to get an array returned from the Oracle stored procedure. Did anyone do something like that? Amy links? Any information on adArray?
    Any advice will be greatly appreciated.

    Lana


  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Array from Oracle stored procedure

    'Here is the code how you can pass array as parameter

    Dim aryTest(1 To 3)

    Private Sub Command1_Click()
    TestArray aryTest
    TestArray
    End Sub

    Private Sub Form_Load()
    aryTest(1) = 1
    aryTest(2) = 2
    aryTest(3) = 3
    End Sub

    Private Sub TestArray(Optional aryToTest)
    If IsMissing(aryToTest) Then
    MsgBox "Array Not Passed"
    Else
    For intCount = 1 To 3
    strMessage = strMessage & "Element " & CStr(intCount) & " = " & CStr(aryToTest(intCount)) & vbLf
    Next
    MsgBox strMessage
    End If
    End Sub





    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  3. #3
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Array from Oracle stored procedure

    Try this also - the function that returns arry

    Private Function Average(ParamArray arguments() As Variant) As Single
    Dim i As Integer
    Dim total As Single

    For i = LBound(arguments) To UBound(arguments)
    total = total + arguments(i)
    Next i
    Average = total / (UBound(arguments) - LBound(arguments))
    End Function

    Private Sub Command1_Click()
    MsgBox Average(1, 2, 3, 4, 5)
    End Sub




    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  4. #4
    Join Date
    Jan 2001
    Posts
    33

    Re: Array from Oracle stored procedure

    The problem is not to pass the array but to get the array from the stored procedure. I am having the problem in communication between the VB data types and Oracle data types. I am getting the "Type name is invalid" error. And it seems that it's coming from the OLEDB provider.
    The code I was using to call the stored procedure:
    Private Sub Command1_Click()
    Dim cn As New ADODB.Connection
    Dim cmd As New ADODB.Command
    Dim prm1 As New ADODB.Parameter, prm2 As New ADODB.Parameter
    Dim strConnect As String, param1() As String, param2 As Integer
    Dim iNumber As Integer

    strConnect = "Data Source=IMSD; User Id=IMS; Password=IMS"
    cn.Open strConnect

    'Create parameters
    With prm1
    .Direction = adParamOutput
    .Type = adArray + adVarChar
    .Value = param1()
    End With

    With prm2
    .Direction = adParamOutput
    .Type = adNumeric
    .Value = param2
    End With

    With cmd
    .CommandText = "temp_array_test_pk.test"
    .CommandType = adCmdStoredProc
    .ActiveConnection = cn
    .Parameters.Append prm1
    .Parameters.Append prm2
    End With

    'Call the stored procedure
    cmd.Execute
    iNumber = cmd.Parameters(1)

    End Sub




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured