Oracle Objects for OLE C++ Class Library
Release 9.2

Part Number A95896-01
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents

Master Index

Feedback

Clone Method

Applies To

ODynaset

Description

This method returns a clone of the ODynaset.

Usage

ODynaset Clone(void)

Remarks

A clone of a parent dynaset is a read-only dynaset that refers to the same local data cache as the parent. It is possible to navigate through the clone dynaset, and read from the clone dynaset, without having any side effects on the parent dynaset. If a dynaset has advisories attached to it or is the dynaset of an OBinder object (which has advisories placed by the OBinder), moving from record to record could be expensive and can even be canceled by an advisory. Cloning the dynaset allows you to look at the data without these side effects.

An ODynaset and its clone can share dynaset marks.

Note that two separate ODynaset objects can refer to the same underlying dynaset. For example, one dynaset can be assigned (using the = operator) to the other. Then, changing the current record in one changes the current record in the other: the current record is changed in the dynaset and the ODynasets are just handles to the dynaset. A Clone is an actual different underlying dynaset, but it observes the same data cache as another dynaset.

Return Value

Returns an ODynaset. If the returned ODynaset is Open (check with the IsOpen method), the Clone was successful. If the returned ODynaset is not Open, the operation failed.

Example

This example creates several ODynaset objects to illustrate relationships between them.

// open the database

ODatabase odb("ExampleDB", "scott/tiger", 0);

// Create some ODynasets.

// ODynaset dyn1 and dyn2 are completely separate

ODynaset dyn1(odb, "select * from emp");

dyn1.MoveFirst();

ODynaset dyn2(odb, "select * from emp");

// ODynaset dyn1copy looks at the same dynaset as dyn1

ODynaset dyn1copy;

dyn1copy = dyn1;

// ODynaset dyn1clone is a clone of dyn1 ...

ODynaset dyn1clone;

// ...which is the same as dyn1copy.Clone()

dyn1clone = dyn1.Clone();

// now dyn1, dyn1copy and dyn1clone are all at the first record

// so now...

dyn1.MoveLast();

// ...dyn1copy is at its last record

// ...but dyn1clone is still at the first

// if we add a record...

dyn1.AddRecord();

/*

Dyn1copy is now current on the new record along with dyn1. dyn1clone is still at the first record.

*/

dyn1.Update(); // add that new record

/*

If we navigate around in dyn1clone we will see the new record, but navigating around in dyn2 we will not see the new record until dyn2 is refreshed.

*/


 
Oracle
Copyright © 1998, 2002 Oracle Corporation.

All Rights Reserved.
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents

Master Index

Feedback