Oracle® Objects for OLE Developer's Guide 10g Release 1 (10.1) Part Number B10118-01 |
|
The following example retrieves data using 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