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

Part Number E17727-03
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

Clone (OraObject/Ref) Method

Applies To

OraObject Object

OraRef Object

Description

Returns the clone of an OraObject or OraRef object.

Usage

Set OraObjectClone = OraObject.CloneSet OraRefClone = OraRef.Clone

Remarks

This method makes a copy of a Value instance or REF value and returns an OraObject or OraRef object associated with that copy. This copy does not change due to a dynaset move operation or OraSQLStmt refresh operation. An OraObject object returned by this method allows an operation to access its attribute values of an underlying value instance and disallows any operation to modify its attribute values.

Examples

Before running the sample code, make sure that you have the necessary data types and tables in the database. For the following examples, see "Schema Objects Used in the OraObject and OraRef Examples"

Example: Clone Method for the OraObject Object

The following example shows the use of the Clone method.

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

Example: Clone Method for the OraRef Object

The following example shows the usage of the Clone method. Before running the sample code, make sure that you have the necessary data types and tables in the database.

Dim OraSession as OraSession
Dim OraDatabase as OraDatabase
Dim OraDynaset as OraDynaset
Dim Person as OraRef
Dim PersonClone as OraRef
 
'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 customers
set OraDynaset = OraDatabase.CreateDynaset("select * from customers", 0&)
 
'retrieve a aperson column from customers. 
'Here Value property of OraField object 'returns Person OraRef
set Person = OraDynaset.Fields("aperson").Value
 
'here Person OraRef points to Person Ref value in the server for the first row 
msgbox Person.Name
 
'move to second row
OraDynaset.MoveNext
 
'here Person OraRef points to Person Ref value in the server for the second row 
msgbox Person.Name
 
'get the clone of Person object. 
'This clone points to the copy of the Ref for second row
set PersonClone = Person.Clone
 
'move to third row
OraDynaset.MoveNext
 
'here Person OraRef points to Person Ref value 
'in the server for the third row 
msgbox Person.Name
 
'here PersonClone OraRef points to Person Ref value 
'in the server for the second row 
msgbox PersonClone.Name