Skip Headers
Oracle® Objects for OLE Developer's Guide
11g Release 2 (11.2) for Microsoft Windows

E17727-04
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
PDF · Mobi · ePub

GetRows Method

Applies To

OraDynaset Object

Description

Retrieves multiple records of a dynaset object into Variant safe array.

Usage

Array =OraDynaset.GetRows(num_rows, start, fields )

Arguments

The arguments for the method are:

Arguments Description
num_rows [optional] An Integer representing the number of records to retrieve. Default value is the total number of rows in the dynaset.
start [optional] An Integer representing the starting position of the dynaset from which the GetRows operation begins. Default value is the current position of the dynaset.
fields [optional] A Variant representing a single field name or field position, or an array of field names or array of field position numbers. The GetRows method returns only the data in these fields.

Remarks

Use the GetRows method to copy records from a dynaset into a two-dimensional array. The first subscript identifies the field and the second identifies the row number. The Array variable is automatically dimensioned to the correct size when the GetRows method returns the data.

Calling the GetRows method does not change the current row position of the dynaset object.

Examples

The following example retrieves data using the GetRows method.

Dim OraSession As OraSession
Dim OraDatabase As OraDatabase
Dim OraDynaset As OraDynaset
Dim row, col As Integer
Dim fields() As String
 
'Create the OraSession Object
Set OraSession = CreateObject("OracleInProcServer.XOraSession")
 
'Create the OraDatabase Object by opening a connection to Oracle
Set OraDatabase = OraSession.OpenDatabase("ExampleDb", _
               "scott/tiger", 0&)
 
Set OraDynaset = OraDatabase.CreateDynaset("select * from emp", 0&)
 
'The following line executes GetRows to get all records
data_array = OraDynaset.GetRows()
 
'Now display all the data in data_array
For row = 0 To UBound(data_array, 2)
    For col = 0 To UBound(data_array, 1)
        Debug.Print data_array(col, row)
    Next col
Next row
 
'The following lines execute GetRows to get the data from
'the ename and empno fields starting at 5
 
ReDim fields(2)
 
fields(0) = "EMPNO"
fields(1) = "ENAME"
 
'Execute GetRows
data_array = OraDynaset.GetRows(, 5, fields)
 
'Now display all the data in data_array
For row = 0 To UBound(data_array, 2)
    For col = 0 To UBound(data_array, 1)
        Debug.Print data_array(col, row)
    Next col
Next row