Represents a large object binary (
LOB) data type stored on an Oracle server. This class cannot be inherited.
public ref class OracleLob sealed : System::IO::Stream, ICloneable, System::Data::SqlTypes::INullable
public sealed class OracleLob : System.IO.Stream, ICloneable, System.Data.SqlTypes.INullable
type OracleLob = class inherit Stream interface ICloneable interface IDisposable interface INullable
Public NotInheritable Class OracleLob Inherits Stream Implements ICloneable, INullable
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.
|OracleType data type||Description|
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
LOBvalue from the Oracle database into the OracleLob class, you can change the
LOBdata in an open transaction and your changes are directly reflected to the database. If you retrieve the Oracle
LOBvalue 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
LOBvalue, only that chunk is passed from the Oracle database to the client. When you use the GetChars method to access a chunk of a
LOBvalue, the entire contents of the value are passed from the Oracle database to the client.
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)
LOB behaves similarly to a zero-byte
LOB in that Read succeeds and always returns zero bytes.
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
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.Value; byte tempbuff = new byte; 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
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
|Null Null Null Null||
Represents a null OracleLob object.
|CanRead CanRead CanRead CanRead||
Gets a value indicating whether the
|CanSeek CanSeek CanSeek CanSeek||
Gets a value indicating whether forward and backward seek operations can be performed.
|CanTimeout CanTimeout CanTimeout CanTimeout||
Gets a value that determines whether the current stream can time out.(Inherited from Stream)
|CanWrite CanWrite CanWrite CanWrite||
Always returns true, regardless of whether the
|ChunkSize ChunkSize ChunkSize ChunkSize||
Gets a value indicating the minimum number of bytes to retrieve from or send to the server during a read/write operation.
|Connection Connection Connection Connection|
|IsBatched IsBatched IsBatched IsBatched||
Gets a value indicating whether an application called the BeginBatch() method.
|IsNull IsNull IsNull IsNull|
|IsTemporary IsTemporary IsTemporary IsTemporary||
Gets a value indicating whether the OracleLob is a temporary
|Length Length Length Length||
Gets a value that returns the size of the OracleLob.
|LobType LobType LobType LobType||
Gets a value that returns the
|Position Position Position Position||
Gets the current read position in the OracleLob stream.
|ReadTimeout ReadTimeout ReadTimeout ReadTimeout||
Gets or sets a value, in miliseconds, that determines how long the stream will attempt to read before timing out.(Inherited from Stream)
|Value Value Value Value||
Gets the common language runtime stream value equivalent of the underlying value.
|WriteTimeout WriteTimeout WriteTimeout WriteTimeout||
Gets or sets a value, in miliseconds, that determines how long the stream will attempt to write before timing out.(Inherited from Stream)
Explicit Interface Implementations
|IDisposable.Dispose() IDisposable.Dispose() IDisposable.Dispose() IDisposable.Dispose()||
Releases all resources used by the Stream.(Inherited from Stream)