Skip Headers

Oracle C++ Call Interface Programmer's Guide
Release 2 (9.2)

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

Master Index

Feedback

Go to previous page Go to beginning of chapter Go to next page

OCCI Classes and Methods, 16 of 22


Ref Class

The mapping in the C++ programming language of an SQL REF value, which is a reference to an SQL structured type value in the database.

Each REF value has a unique identifier of the object it refers to. An SQL REF value may be used in place of the SQL structured type it references; it may be used as either a column value in a table or an attribute value in a structured type.

Because an SQL REF value is a logical pointer to an SQL structured type, a Ref object is by default also a logical pointer; thus, retrieving an SQL REF value as a Ref object does not materialize the attributes of the structured type on the client.

A Ref object can be saved to persistent storage and is de-referenced through operator* or operator-> or ptr() methods. T must be a class derived from PObject. In the following sections, T* and PObject* are used interchangeably.

To create a null Ref object, use the syntax:

Ref();

The only methods valid on a null Ref object are isNull, and operator=().

To create a copy of a Ref object, use the syntax:

Ref(const Ref<T> &src);

Summary of Ref Methods

Table 8-16 Ref Methods  
Method Summary

clear()

Clears the reference.

getConnection()

Returns the connection this ref was created from.

getRef()

Returns the Ref.

isClear()

Checks if the Ref is cleared.

isNull()

This method checks if the Ref is null.

markDelete()

Marks the referred object as deleted.

operator->()

De-reference the Ref and pins the object if necessary.

operator*()

This operator de-references the Ref and pins / fetches the object if necessary.

operator==()

Checks if the Ref and the pointer refer to the same object.

operator!=()

Checks if the Ref and the pointer refer to different objects.

operator=()

Assignment operator.

ptr()

De-references the Ref and pins / fetches the object if necessary.

setPrefetch()

Specifies type and depth of the object attributes to be followed for prefetching.

setLock()

Sets the lock option for the object referred from this.

setNull()

Sets the Ref to NULL.

unmarkDelete()

Unmarks for delete the object referred by this.

clear()

This method clears the Ref object.

Syntax
void clear();

getConnection()

This method returns the connection from which the Ref object was instantiated.

Syntax
const Connection *getConnection() const;

getRef()

This method returns the OCI Ref from the Ref object.

Syntax
LNOCIRef *getRef() const;

isClear()

This method checks if Ref object is cleared.

Syntax
bool isClear();

isNull()

This method tests whether the Ref object is null. If the Ref object is null, then true is returned; otherwise, false is returned.

Syntax
bool isNull() const;

markDelete()

This method marks the referenced object as deleted.

Syntax
void markDelete();

operator->()

This method dereferences the Ref object and pins or fetches the referenced object if necessary. This might result in prefetching a graph of objects if prefetch attributes of the referenced object are set.

Syntax

There are variants of syntax:

T * operator->();
const T * operator->() const;

operator*()

This method dereferences the Ref object and pins or fetches the referenced object if necessary. This might result in prefetching a graph of objects if prefetch attributes of the referenced object are set.

The object does not need to be deleted. Destructor would be automatically called when it goes out of scope.

Syntax

There are variants of syntax:

T & operator *();
const T & operator*() const;

operator==()

This method tests whether two Ref objects are referencing the same object. If the Ref objects are referencing the same object, then true is returned; otherwise, false is returned.

Syntax
bool operator == (const Ref<T> &ref) const;
Parameters
ref

The Ref object of the object to be compared.

operator!=()

This method tests whether two Ref objects are referencing the same object. If the Ref objects are not referencing the same object, then true is returned; otherwise, false is returned.

Syntax
bool operator!= (const Ref<T> &ref) const;
Parameters
ref

The Ref object of the object to be compared.

operator=()

Assigns the ref or the object to a ref. For the first case, the refs are assigned and for the second case, the ref is constructed from the object and then assigned.

Syntax

There are variants of syntax:

Ref<T>& operator=(const Ref<T> &src);
Ref<T>& operator=(const T *obj);
Parameters
src

The source Ref object to be assigned.

obj

The source object pointer whose Ref object is to be assigned.

ptr()

This operator dereferences the Ref and pins/fetches the object if necessary. This might result in prefetching a graph of objects if prefetch attributes of the Ref are set.

Syntax

There are variants of syntax:

T * ptr();
const T * ptr() const;

setPrefetch()

Sets the prefetching options for the complex object retrieval.

This method specifies depth up to which all objects reachable from this object through Refs (transitive closure) should be prefetched. If only selected attribute types are to be prefetched, then setPrefetch(type_name, depth) should be used.

This method specifies which Ref attributes of the object it refers to should be followed for prefetching of the objects (complex object retrieval) and how many levels deep those links should be followed.

Syntax

There are variants of syntax:

void setPrefetch(const string &typeName,
   unsigned int depth);
void setPrefetch(unsigned int depth);
Parameters
typeName

Type of the Ref attribute to be prefetched.

depth

Depth level to which the links should be followed.

setLock()

This method specifies how the object should be locked when dereferenced.

Syntax
void setLock(LockOptions);
Parameters
LockOptions

The lock options.

Valid values are:

OCCI_LOCK_NONE

OCCI_LOCK_X

OCCI_LOCK_X_NOWAIT

setNull()

This method sets the Ref object to NULL.

Syntax
void setNull();

unmarkDelete()

This method unmarks the referred object as dirty.

Syntax
void unmarkDelete();


Go to previous page Go to beginning of chapter Go to next page
Oracle
Copyright © 2001, 2002 Oracle Corporation.

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

Master Index

Feedback