Skip Headers
Oracle® Data Provider for .NET Developer's Guide
11g Release 2 (11.2.0.3)

Part Number E23174-02
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

OracleRef Class

An OracleRef instance represents an Oracle REF, which references a persistent, standalone, referenceable object that resides in the database. The OracleRef object provides methods to insert, update, and delete the Oracle REF.

Class Inheritance

System.Object

  System.MarshalByRefObject

    Oracle.DataAccess.Types.OracleRef

Declaration

// C#
public sealed class OracleRef : MarshalByRefObject,ICloneable, IDisposable,  
  INullable 

Thread Safety

All public static methods are thread-safe, although instance methods do not guarantee thread safety.

Remarks

If two or more OracleRef objects that refer to the same Oracle object in the database are retrieved through the same OracleConnection, then their operations on the referenced object must be synchronized.

Requirements

Namespace: Oracle.DataAccess.Types

Assembly: Oracle.DataAccess.dll

ODP.NET Version: ODP.NET for .NET Framework 2.0 or ODP.NET for .NET Framework 4


OracleRef Members

OracleRef members are listed in the following tables.

OracleRef Constructors

OracleRef constructors are listed in Table 16-30.

Table 16-30 OracleRef Constructors

Constructor Description

OracleRef Constructors

Instantiates a new instance of OracleRef class (Overloaded)


OracleRef Static Fields

OracleRef static methods are listed in Table 16-31

Table 16-31 OracleRef Static Fields

Static Field Description

Null

Represents a null value that can be assigned to an OracleRef instance


OracleRef Static Methods

OracleRef static methods are listed in Table 16-32.

Table 16-32 OracleRef Static Methods

Method Description

Equals

Inherited from System.Object (Overloaded)


OracleRef Instance Properties

OracleRef instance properties are listed in Table 16-33.

Table 16-33 OracleRef Instance Properties

Property Description

Connection

References the connection used by the OracleRef

HasChanges

References the connection used by the OracleRef

IsLocked

Indicates whether or not the REF is locked

IsNull

Indicates whether or not the Oracle REF is NULL

ObjectTableName

Returns the fully qualified object table name that is associated with the REF

Value

Returns a .NET representation of this Oracle REF


OracleRef Instance Methods

OracleRef instance methods are listed in Table 16-34.

Table 16-34 OracleRef Instance Methods

Method Description

Clone

Clones the REF

Delete

Deletes the referenced object from the database

Dispose

Releases resources allocated for the OracleRef instance

Equals

Inherited from System.Object

Flush

Flushes changes made on the REF object to the database

GetCustomObject

Returns the object that the specified REF references as a custom type (Overloaded)

GetCustomObjectForUpdate

Returns the object that the specified REF references as a custom type (Overloaded)

GetHashCode

Inherited from System.Object

GetType

Inherited from System.Object

IsEqual

Compares two OracleREF objects

Lock

Locks the REF in the database

ToString

Inherited from System.Object

Update

Updates the object referenced by the specified REF in the database using the specified custom object



OracleRef Constructors

OracleRef constructors instantiate new instances of OracleRef class.

Overload List:

OracleRef(OracleConnection, string)

This constructor creates an instance of the OracleRef class with a connection and a HEX string that represents an REF instance in the database.

Declaration

// C#
public OracleRef(OracleConnection con, string hexStr);

Parameters

Exceptions

ArgumentException - The HEX string does not represent a valid REF in the database.

ArgumentNullException - The connection or HEX string is null.

InvalidOperationException - The OracleConnection object is not open.

Remarks

When an OracleRef instance is created, it is referenced to a specific table in the database.

The connection must be opened explicitly by the application. OracleRef does not open the connection implicitly.

OracleRef(OracleConnection, string, string)

This constructor creates an instance of the OracleRef class using the specified OracleConnection object, user-defined type name, and an object table name.

Declaration

// C#
public OracleRef(OracleConnection con, string udtTypeName, string objTabName);

Parameters

Exceptions

ArgumentException - The object type name or the object table name is not valid.

ArgumentNullException - The object type name or the table name is null.

InvalidOperationException - The OracleConnection object is not open.

Remarks

When an OracleRef instance is created, this OracleRef instance is associated with the specific table in the database. In other words, it represents a persistent REF.

This constructor creates a reference to the object table. However, it does not cause any entries to be made in database tables until the object is flushed to the database, that is, until the OracleRef.Flush or the OracleConnection.FlushCache method is called on the OracleRef Connection. Therefore, any operation that attempts to operate on the database copy of the object before flushing the object, such as, lock the object or fetch the latest copy of the object from the database, results in an OracleException.

The connection must be opened explicitly by the application. OracleRef does not open the connection implicitly.


OracleRef Static Fields

OracleRef static fields are listed in Table 16-35.

Table 16-35 OracleRef Static Fields

Static Field Description

Null

Represents a null value that can be assigned to an OracleRef instance


Null

This static field represents a null value that can be assigned to an OracleRef instance.

Declaration

// C#
public static readonly OracleRef Null;

OracleRef Static Methods

OracleRef static methods are listed in Table 16-36.

Table 16-36 OracleRef Static Methods

Method Description

Equals

Inherited from System.Object (Overloaded)



OracleRef Instance Properties

OracleRef instance properties are listed in Table 16-37.

Table 16-37 OracleRef Instance Properties

Property Description

Connection

References the connection used by the OracleRef

HasChanges

References the connection used by the OracleRef

IsLocked

Indicates whether or not the REF is locked

IsNull

Indicates whether or not the Oracle REF is NULL

ObjectTableName

Returns the fully qualified object table name that is associated with the REF

Value

Returns a .NET representation of this Oracle REF


Connection

This instance property references the connection used by the OracleRef.

Declaration

// C#
public OracleConnection Connection{get;}

Property Value

An OracleConnection object associated with the REF.

Exceptions

ObjectDisposedException - The object is already disposed.

Remarks

Once the Dispose method is invoked, this property is set to null.

HasChanges

This instance property indicates whether or not the object referenced by the Oracle REF in the object cache has any changes that can be flushed to the database.

Declaration

// C#
public bool HasChanges {get;}

Property Value

Returns true if the object referenced by the Oracle REF in the object cache has any changes that can be flushed to the database; otherwise, returns false.

Exceptions

ObjectDisposedException - The object is already disposed.

Remarks

This property returns true if a copy of the referenced object in the object cache is updated or deleted.

If there is no copy of the referenced object in the object cache, the latest copy of the referenced object in the database is cached in the object cache and false is returned.

IsLocked

This instance property indicates whether or not the REF is locked.

Declaration

// C#
public bool IsLocked {get;}

Property Value

Returns true if the REF is locked; otherwise returns false.

Exceptions

ObjectDisposedException - The object is already disposed.

IsNull

This instance property indicates whether or not the Oracle REF is NULL.

Declaration

// C#
public bool IsNull {get;}

Property Value

Returns true if the REF is NULL; otherwise, returns false.

Exceptions

ObjectDisposedException - The object is already disposed.

Remarks

If the Oracle REF is NULL, this property returns true. Otherwise, it returns false.

ObjectTableName

This instance property returns the fully-qualified object table name that is associated with the REF.

Declaration

// C#
public string ObjectTableName{get;}

Property Value

A fully-qualified object table name that is associated with the REF.

Exceptions

ObjectDisposedException - The object is already disposed.

Remarks

The object table name is in the form schema_Name.Table_Name.

Value

This instance property returns a .NET representation of this Oracle REF.

Declaration

// C#
public string Value{get;}

Property Value

A .NET representation of the Oracle REF.

Exceptions

ObjectDisposedException - The object is already disposed.

Remarks

This property returns a HEX string that represents the REF.

The returned string can be used to create a new OracleRef instance by using the OracleRef(OracleConnection, string) constructor.


Oracle Ref Instance Methods

OracleRef instance methods are listed in Table 16-38.

Table 16-38 OracleRef Instance Methods

Method Description

Clone

Clones the REF

Delete

Deletes the referenced object from the database

Dispose

Releases resources allocated for the OracleRef instance

Equals

Inherited from System.Object

Flush

Flushes changes made on the REF object to the database

GetCustomObject

Returns the object that the specified REF references as a custom type (Overloaded)

GetCustomObjectForUpdate

Returns the object that the specified REF references as a custom type (Overloaded)

GetHashCode

Inherited from System.Object

GetType

Inherited from System.Object

IsEqual

Compares two OracleREF objects

Lock

Locks the REF in the database

ToString

Inherited from System.Object

Update

Updates the object referenced by the specified REF in the database using the specified custom object


Clone

This instance method clones the REF.

Declaration

// C#
public OracleRef Clone();

Return Value

A clone of the current instance.

Implements

ICloneable

Exceptions

InvalidOperationException - The associated connection is not open.

Delete

This method deletes the referenced object from the database.

Declaration

// C#
public void Delete(bool bFlush);

Parameters

Remarks

This method marks the specified REF for deletion.

Depending on whether the value of bFlush is set to true or false, the following occurs:

Dispose

This instance method releases resources allocated for the OracleRef instance.

Declaration

// C#
public void Dispose();

Implements

IDisposable

Remarks

The object cannot be reused after it is disposed. Although some properties can still be accessed, their values may not be up-to-date.

Flush

This instance method flushes changes made on the REF object to the database, such as updates or deletes.

Declaration

// C#
public void Flush();

Exceptions

InvalidOperationException - The associated connection is not open.

Remarks

Before flushing objects, it is required that the application has explicitly started a transaction by executing the BeginTransaction method on the OracleConnection object. This is because if the object being flushed has not already been locked by the application, an exclusive lock is obtained implicitly for the object. The lock is only released when the transaction commits or rollbacks.

GetCustomObject

GetCustomObject methods return the object that the specified REF references as a custom type.

Overload List

GetCustomObject(OracleUdtFetchOption)

This method returns the object that the specified REF references, as a custom type, using the specified fetch option.

Declaration

// C#
public object GetCustomObject(OracleUdtFetchOption fetchOption);

Parameters

Return Value

A custom object that represents the object that the specified REF references.

Exceptions

InvalidOperationException - The specified connection is not open, or a valid custom type has not been registered for the type of the referenced object.

Remarks

This method returns a custom type determined by the UDT mappings on the specified connection.

The connection must be opened explicitly by the application. This method does not open the connection implicitly.

The application can use the OracleUdtFetchOption method to control the copy of the Object that is returned according to the specified option:

GetCustomObject(OracleUdtFetchOption, int)

This method returns the object that the specified REF references, as a custom type, using the specified fetch option and depth level.

Declaration

// C#
public object GetCustomObject(OracleUdtFetchOption fetchOption, int depthLevel);

Parameters

Return Value

A custom object that represents the object that the specified REF references.

Exceptions

InvalidOperationException - The specified connection is not open, or a valid custom type has not been registered for the type of the referenced object.

Remarks

This method returns a custom type determined by the UDT mappings on the specified connection.

If the object that the REF references contains nested REF attributes, the depthLevel can be specified to optimize the subsequent object retrieval. The value of depthLevel determines the number of levels that are optimized.

For example, if the depthLevel is specified as two, the optimization is applied to all top-level nested REF attributes in the object being fetched and also to all nested REF attributes within the objects referenced by the top-level nested REF attributes.

The connection must be opened explicitly by the application. This method does not open the connection implicitly.

The application can use the OracleUdtFetchOption method to control the copy of the Object that is returned according to the specified option:

GetCustomObjectForUpdate

GetCustomObjectForUpdate methods return the object that the specified REF references as a custom type.

GetCustomObjectForUpdate(bool)

This method locks the specified REF in the database and returns the object that the specified REF references, as a custom type, using the specified wait option.

Declaration

// C#
public object GetCustomObjectForUpdate(bool bWait);

Parameters

Return Value

A custom object that represents the object that the specified REF references.

Exceptions

InvalidOperationException - The specified connection is not open, or a valid custom type has not been registered for type of the referenced object.

OracleException - bWait is set to false, and the lock cannot be acquired.

Remarks

This method returns the latest copy of the referenced object, as a custom type, determined by the custom types registered on the OracleRef connection.

To be able to release the lock on the REF appropriately after flushing the REF using the Flush method on the OracleRef or FlushCache method on the OracleConnection, the application must commit or rollback the transaction. Therefore, it is required that, before invoking this method, a transaction is explicitly started by executing the BeginTransaction method on the OracleConnection object.

This method makes a network round-trip to lock the REF in the database. After this call, programmers can modify the associated row object exclusively. Then a call to the Flush method on the OracleRef or FlushCache method on the OracleConnection flushes the changes to the database.

If true is passed, this method blocks until the lock can be acquired. If false is passed, this method immediately returns. If the lock cannot be acquired, an OracleException is thrown.

The connection must be opened explicitly by the application. This method does not open the connection implicitly.

GetCustomObjectForUpdate(bool, int)

This method locks the specified REF in the database and returns the object that the specified REF references, as a custom type, using the specified wait option and depth level

Declaration

public object GetCustomObjectForUpdate(bool bWait, int depthlevel);

Parameters

Return Value

A custom object that represents the object that the specified REF references.

Exceptions

InvalidOperationException - The specified connection is not open, or a valid custom type has not been registered for type of the referenced object.

OracleException - bWait is set to false, and the lock cannot be acquired.

Remarks

This method returns the latest copy of the referenced object, as a custom type, determined by the custom types registered on the OracleRef connection.

To be able to release the lock on the REF appropriately after flushing the REF using the Flush method on the OracleRef or FlushCache method on the OracleConnection, the application must commit or rollback the transaction. Therefore, it is required that, before invoking this method, a transaction is explicitly started by executing the BeginTransaction method on the OracleConnection object.

This method makes a network round-trip to lock the REF in the database. After this call, programmers can modify the associated row object exclusively. Then a call to the Flush method on the OracleRef or FlushCache method on the OracleConnection flushes the changes to the database.

If true is passed, this method blocks until the lock can be acquired. If false is passed, this method immediately returns. If the lock cannot be acquired, an OracleException is thrown.

If the object that the REF references contains nested REF attributes, the depthLevel can be specified to optimize the subsequent object retrieval. The value of depthLevel determines the number of levels that are optimized.

For example, if the depthLevel is specified as 2, the optimization is applied to all top-level nested REF attributes in the object being fetched and also to all nested REF attributes within the objects referenced by the top-level nested REF attributes.

The connection must be opened explicitly by the application. This method does not open the connection implicitly.

IsEqual

This instance method compares two OracleREF objects.

Declaration

// C#
public bool IsEqual(OracleRef oraRef);

Parameters

Return Value

bool

Remarks

This instance method returns true if the OracleRef instance and the OracleRef parameter both reference the same object. Otherwise, it returns false.

Lock

This instance method locks the REF in the database.

Declaration

// C#
public bool Lock(bool bWait);

Parameters

Return Value

A boolean value that indicates whether or not the lock has been acquired.

Exceptions

InvalidOperationException - The associated connection is not open.

ObjectDisposedException - The object is already disposed.

Remarks

In order for the application to release the lock on the REF appropriately after the Flush invocation on the OracleRef or FlushCache methods, the application must commit or rollback the transaction. Therefore, it is required that, before invoking a lock on an OracleRef object, a transaction is explicitly started by executing the BeginTransaction method on the OracleConnection object.

This instance method makes a network round-trip to lock the REF in the database. After this call, programmers can modify the attribute values of the associated row object exclusively. Then a call to the Flush instance method on the OracleRef or FlushCache method on the OracleConnection flushes the changes to the database.

If true is passed, this method blocks, that is, does not return, until the lock is acquired. Consequently, the return value is always true.

If false is passed, this method immediately returns. The return value indicates true if the lock is acquired, and false if it is not.

Update

This method updates the object referenced by the specified REF in the database using the specified custom object.

Declaration

// C#
public void Update(object customObject, bool bFlush);

Parameters

Exceptions

InvalidOperationException - The specified connection is not open or the custom object does not map to the type of referenced object.

Remarks

This method marks the specified REF for update. Depending on whether the value of bFlush is set to true or false, the following occurs:

The connection must be opened explicitly by the application. This method does not open the connection implicitly.