Skip Headers

Oracle® Objects for OLE C++ Class Library Developer's Guide
Release 9.2.0.4

Part Number B10954-01
Go To Table Of Contents
Contents

operator=

Applies To

OAdvise, OClient, OConnection, OConnectionCollection, ODatabase, ODatabaseCollection, ODynaset, ODynasetMark, OField, OFieldCollection, OParameter, OParameterCollection, OSession, OSessionCollection, OValue, OAQ, OAQAgent, OAQMsg, OBfile, OBlob, OClob, OCollection, OException, OMDAttribute, OMetaData, OObject, ORef, OServer, OSnapshotID

Description

This method assigns one object to another.

Usage

OAdvise &OAdvise::operator =(const OAdvise &other)

OClient &OClient::operator =(const OClient &other)

OConnection &OConnection::operator =(const OConnection &other)

OConnectionCollection &OConnectionCollection::operator =(const OConnectionCollection &other)

ODatabase &ODatabase::operator =(const ODatabase &other)

ODatabaseCollection &ODatabaseCollection::operator =(const ODatabaseCollection &other)

ODynaset &ODynaset::operator =(const ODynaset &other)

ODynasetMark &ODynasetMark::operator =(const ODynasetMark &other)

OField &OField::operator =(const OField &other)

OFieldCollection &OFieldCollection::operator =(const OFieldCollection &other)

OParameter &OParameter::operator =(const OParameter &other)

OParameterCollection &OParameterCollection::operator =(const OParameterCollection &other)

OSession &OSession::operator =(const OSession &other)

OSessionCollection &OSessionCollection::operator =(const OSessionCollection &other)

OValue &OValue::operator =(const OValue &other)

OAQ &OAQ::operator =(const OAQ &other)

OAQAgent &OAQAgent::operator =(const OAQAgent &other)

OAQMsg &OAQMsg::operator =(const OAQMsg &other)

OBfile &OBfile::operator =(const OBfile &other)

OBlob &OBlob::operator =(const OBlob &other)

OClob &OClob::operator =(const OClob &other)

OException &OException::operator =(const OException &other)

OMDAttribute &OMDAttribute::operator =(const OMDAttribute &other)

OMetaData &OMetaData::operator =(const OMetaData &other)

OObject &OObject::operator =(const OObject &other)

OCollection &OCollection::operator =(const OCollection &other)

ORef &ORef::operator =(const ORef &other)

OServer &OServer::operator =(const OServer &other)

OSnapShotID &OSnapShotID::operator =(const OSnapShotID &other)

Arguments

other
The object that is the source of the assignment.
Remarks

The assignment operator makes the object a copy of another object.

For the classes OAdvise, OClient, OConnection, OConnectionCollection, ODatabase, ODynaset, OField, OFieldCollection, OParameter, OParameterCollection, OSession, and OSessionCollection, a copied object becomes another handle that refers to the same underlying implementation object. Strings owned by the source object are not copied to the destination object (although the same information - such as database name and SQL statement - are available from the new object).

Note: For OField, what is being copied is not the value of the field, but the OField handle itself.

ODynasetMark and OValue are simpler objects. The data of the source object is simply copied.

If the object is already open, it is closed before the assignment. As a result, if the assignment fails, the return value of the operation will be a closed object.

The work that is done by assigning is the same as for a copy constructor.

OBinder and OBound have operator= defined in the header file, but the operator is not implemented. This is done so that the compiler's default implementation will not be used (it would be incorrect). If you want an assignment operator for your OBinder or OBound subclass, you must implement it.

Return Value

The object that was assigned to.

Example

An illustration of the meaning of assignment:

// open an ODatabase

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

// open an ODynaset

ODynaset odyn(odb, "select ename, sal, comm from employees");

// get a field on sal and commission

OField salfield = odyn.GetField("sal");

OField commfield = odyn.GetField("comm");

// declare some OValue variables

OValue salval;

OValue commval;

// now look at the values of the first record

odyn.GetFieldValue("sal", &salval);

odyn.GetFieldValue("comm", &commval);

// let us say that salval contains 5000 and commval contains 300

salval = bonusval; // assign commission value to salary

// now salval contains 300

// can we do the same with OFields? NO!

int isal = (int) salfield; // isal is now 5000

int ibonus = (int) commfield; // ibonus is now 300

salfield = commfield; // assign comm OField to salary OField

// NOTE: we have only assigned the OField variable

int isal2 = (int) salfield; // isal2 is 300

/*

isal2 is 300 because salfield is now referring to the field "comm" in the record.

*/

// now update the record

odyn.StartEdit()

salfield.SetValue(4000);

odyn.Update();

// we have just set the "comm" field to 4000, not the "sal" field


 
Oracle
Copyright © 1998, 2003 Oracle Corporation.

All Rights Reserved.
Go To Table Of Contents
Contents