Oracle® Objects for OLE Developer's Guide 11g Release 2 (11.2) for Microsoft Windows Part Number E17727-03 |
|
|
PDF · Mobi · ePub |
Retrieves multiple records of a dynaset object into Variant
safe array.
Array =OraDynaset.GetRows(num_rows, start, fields )
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. |
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.
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