Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

OracleLob Class

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

Namespace: System.Data.OracleClient
Assembly: System.Data.OracleClient (in system.data.oracleclient.dll)

Public NotInheritable Class OracleLob
	Inherits Stream
	Implements ICloneable, IDisposable, INullable
Dim instance As OracleLob

public final class OracleLob extends Stream implements ICloneable, IDisposable, 
public final class OracleLob extends Stream implements ICloneable, IDisposable, 

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



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


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


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

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;");
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;
OracleLob tempLob = (OracleLob)command.Parameters[0].Value;
byte[] tempbuff = new byte[10000];
command.CommandText = "MyTable.MyProc";
command.CommandType = CommandType.StoredProcedure;  
command.Parameters.Add(new OracleParameter("ImportDoc", OracleType.Blob)).Value = tempLob;

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


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1

Community Additions

© 2015 Microsoft