Export (0) Print
Expand All
1 out of 1 rated this helpful - Rate this topic

OracleLob Class

Represents a large object binary (LOB) data type stored on an Oracle server. This class cannot be inherited.

System::Object
  System::MarshalByRefObject
    System.IO::Stream
      System.Data.OracleClient::OracleLob

Namespace:  System.Data.OracleClient
Assembly:  System.Data.OracleClient (in System.Data.OracleClient.dll)
public ref class OracleLob sealed : public Stream, 
	ICloneable, IDisposable, INullable

The OracleLob type exposes the following members.

  NameDescription
Public propertyCanReadGets a value indicating whether the LOB stream can be read. (Overrides Stream::CanRead.)
Public propertyCanSeekGets a value indicating whether forward and backward seek operations can be performed. (Overrides Stream::CanSeek.)
Public propertyCanTimeoutGets a value that determines whether the current stream can time out. (Inherited from Stream.)
Public propertyCanWriteAlways returns true, regardless of whether the LOB supports writing or not. (Overrides Stream::CanWrite.)
Public propertyChunkSizeGets a value indicating the minimum number of bytes to retrieve from or send to the server during a read/write operation.
Public propertyConnectionGets the OracleConnection used by this instance of the OracleLob.
Public propertyIsBatchedGets a value indicating whether an application called the BeginBatch method.
Public propertyIsNullGets a value that indicates whether the OracleLob is a Null stream.
Public propertyIsTemporaryGets a value indicating whether the OracleLob is a temporary LOB.
Public propertyLengthGets a value that returns the size of the OracleLob. (Overrides Stream::Length.)
Public propertyLobTypeGets a value that returns the LOB data type.
Public propertyPositionGets the current read position in the OracleLob stream. (Overrides Stream::Position.)
Public propertyReadTimeoutGets or sets a value, in miliseconds, that determines how long the stream will attempt to read before timing out. (Inherited from Stream.)
Public propertyValueGets the common language runtime stream value equivalent of the underlying value.
Public propertyWriteTimeoutGets or sets a value, in miliseconds, that determines how long the stream will attempt to write before timing out. (Inherited from Stream.)
Top
  NameDescription
Public methodAppendAppends data from the specified LOB to the current LOB.
Public methodBeginBatch()Prevents server-side triggers from firing while performing multiple read operations.
Public methodBeginBatch(OracleLobOpenMode)Prevents server-side triggers from firing while performing multiple read and write operations in the specified access mode.
Public methodBeginReadBegins an asynchronous read operation. (Inherited from Stream.)
Public methodBeginWriteBegins an asynchronous write operation. (Inherited from Stream.)
Public methodCloneCreates a new OracleLob object that references the same Oracle LOB as the original OracleLob object.
Public methodCloseCloses the current stream and releases any resources (such as sockets and file handles) associated with the current stream. (Inherited from Stream.)
Public methodCopyTo(OracleLob)Copies from this OracleLob to a destination OracleLob.
Public methodCopyTo(Stream)Reads the bytes from the current stream and writes them to the destination stream. (Inherited from Stream.)
Public methodCopyTo(OracleLob, Int64)Copies from this OracleLob to a destination OracleLob with the specified amount of data.
Public methodCopyTo(Stream, Int32)Reads all the bytes from the current stream and writes them to a destination stream, using a specified buffer size. (Inherited from Stream.)
Public methodCopyTo(Int64, OracleLob, Int64, Int64)Copies from this OracleLob to a destination OracleLob with the specified amount of data, and the source offset.
Public methodCreateObjRefCreates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.)
Protected methodCreateWaitHandle Obsolete. Allocates a WaitHandle object. (Inherited from Stream.)
Public methodDispose()Releases all resources used by the Stream. (Inherited from Stream.)
Protected methodDispose(Boolean)Releases the unmanaged resources used by the Stream and optionally releases the managed resources. (Inherited from Stream.)
Public methodEndBatchAllows server-side triggers to resume firing after performing multiple write operations.
Public methodEndReadWaits for the pending asynchronous read to complete. (Inherited from Stream.)
Public methodEndWriteEnds an asynchronous write operation. (Inherited from Stream.)
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Public methodErase()Erases all data from this OracleLob.
Public methodErase(Int64, Int64)Erases the specified amount of data from this OracleLob.
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodFlushNot currently supported. (Overrides Stream::Flush().)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetLifetimeServiceRetrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodInitializeLifetimeServiceObtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Protected methodMemberwiseClone()Creates a shallow copy of the current Object. (Inherited from Object.)
Protected methodMemberwiseClone(Boolean)Creates a shallow copy of the current MarshalByRefObject object. (Inherited from MarshalByRefObject.)
Protected methodObjectInvariantInfrastructure. Provides support for a Contract. (Inherited from Stream.)
Public methodReadReads a sequence of bytes from the current OracleLob stream and advances the position within the stream by the number of bytes read. (Overrides Stream::Read(array<Byte>, Int32, Int32).)
Public methodReadByteReads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream. (Inherited from Stream.)
Public methodSeekSets the position on the current OracleLob stream. (Overrides Stream::Seek(Int64, SeekOrigin).)
Public methodSetLengthSets the length of the OracleLob stream to a value less than the current length. (Overrides Stream::SetLength(Int64).)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Public methodWriteWrites a sequence of bytes to the current OracleLob stream, and advances the current position within this stream by the number of bytes written. (Overrides Stream::Write(array<Byte>, Int32, Int32).)
Public methodWriteByteWrites a byte to the current position in the OracleLob stream, and advances the position within the stream by one byte. (Overrides Stream::WriteByte(Byte).)
Top
  NameDescription
Public fieldStatic memberNullRepresents a null OracleLob object.
Top

An OracleLob differs from an OracleBFile in that the data is stored on the server instead of in a physical file in the operating system. It can also be a read-write object, unlike an OracleBFile, which is always read-only.

An OracleLob may be one of these OracleType data types.

OracleType data type

Description

Blob

An Oracle BLOB data type that contains binary data with a maximum size of 4 gigabytes (GB). This maps to an Array of type Byte.

Clob

An Oracle CLOB data type that contains character data, based on the default character set on the server, with a maximum size of 4 GB. This maps to String.

NClob

An Oracle NCLOB data type that contains character data, based on the national character set on the server with a maximum size of 4 GB. This maps to String.

A .NET application developer can retrieve the Oracle LOB values into basic .NET data types, such as Array of type Byte and String, or the specialized OracleLob data type. The OracleLob class supports reading data from and writing to the Oracle LOB in the Oracle database.

The following are the main characteristics of an OracleLob data type that distinguish it from basic .NET data types:

  • After you retrieve the Oracle LOB value from the Oracle database into the OracleLob class, you can change the LOB data in an open transaction and your changes are directly reflected to the database. If you retrieve the Oracle LOB value into an Array of type Byte or String and update these arrays, your changes are not reflected to the database.

  • When you use the OracleLob class to access a chunk of a LOB value, only that chunk is passed from the Oracle database to the client. When you use the GetChars method to access a chunk of a LOB value, the entire contents of the value are passed from the Oracle database to the client.

To obtain an OracleLob object, call the GetOracleLob method.

You can construct an OracleLob that is NULL using this format:

OracleLob myLob = OracleLob.Null;

This technique is used primarily to test whether a LOB returned from the server is NULL, as this example illustrates:

If(myLob == OracleLob.Null)

A NULL LOB behaves similarly to a zero-byte LOB in that Read succeeds and always returns zero bytes.

Selecting a LOB column that contains a null value returns Null.

You must begin a transaction before obtaining a temporary LOB. Otherwise, the OracleDataReader may fail to obtain data later.

You can also open a temporary LOB in Oracle by calling the DBMS_LOB.CREATETEMPORARY system stored procedure and binding a LOB output parameter. On the client side, a temporary LOB behaves like a table-based LOB. For example, to update the temporary LOB, it must be enclosed in a transaction.

The following C# example demonstrates how to open a temporary LOB.

OracleConnection connection = new OracleConnection("server=MyServer; integrated security=yes;");
connection.Open();
OracleTransaction transaction = connection.BeginTransaction();
OracleCommand command = connection.CreateCommand();
command.Transaction = transaction;
command.CommandText = "declare xx blob; begin dbms_lob.createtemporary(xx, false, 0); :tempblob := xx; end;";
command.Parameters.Add(new OracleParameter("tempblob", OracleType.Blob)).Direction = ParameterDirection.Output;
command.ExecuteNonQuery();
OracleLob tempLob = (OracleLob)command.Parameters[0].Value;
byte[] tempbuff = new byte[10000];
tempLob.BeginBatch(OracleLobOpenMode.ReadWrite);
tempLob.Write(tempbuff,0,tempbuff.Length);
tempLob.EndBatch();
command.Parameters.Clear();
command.CommandText = "MyTable.MyProc";
command.CommandType = CommandType.StoredProcedure;  
command.Parameters.Add(new OracleParameter("ImportDoc", OracleType.Blob)).Value = tempLob;
command.ExecuteNonQuery();
transaction.Commit();
connection.Close
NoteNote

The inherited WriteByte method fails if used with character data, and an InvalidOperationException is thrown. Use the Write method instead.

Temporary LOBs are only closed when the connection is closed, but with pooling and under load, temporary LOBs do not close. This can be resolved by disposing the temporary LOB, by invoking tempLob.Dispose().

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.