Oracle® Objects for OLE Developer's Guide 10g Release 1 (10.1) Part Number B10118-01 |
|
The following example shows the usage of the Clone method. Before running the sample code, make sure that you have the necessary datatypes and tables in the database. See Schema Description used in examples of OraObject/OraRef.
Dim OraSession as OraSession
Dim OraDatabase as OraDatabase
Dim OraDynaset as OraDynaset
Dim Address as OraObject
Dim AddressClone as OraObject
'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&)
'create a dynaset object from person_tab
set OraDynaset = OraDatabase.CreateDynaset("select * from person_tab",0&)
'retrieve a address column from person_tab. Here Value property of OraField object
'returns Address OraObject
set Address = OraDynaset.Fields("Addr").Value
'here Address OraObject points to Address value instance in the server for the first row
msgbox Address.Street
'move to second row
OraDynaset.MoveNext
'here Address OraObject points to Address value instance in the server for the second row
msgbox Address.Street
'get the clone of Address object. This clone points to the copy of the value instance for
'second row
set AddressClone = Address.Clone
'move to third row
OraDynaset.MoveNext
'here Address OraObject points to Address value instance in the server for third row
msgbox Address.Street
'here AddressClone OraObject points to copy of Address value instance in the server
'for second row
msgbox AddressClone.Street