OracleLob Class
Represents a Large Object Binary (LOB) data type stored on an Oracle server. This class cannot be inherited.
For a list of all members of this type, see OracleLob Members.
System.Object
System.MarshalByRefObject
System.IO.Stream
System.Data.OracleClient.OracleLob
[Visual Basic] NotInheritable Public Class OracleLob Inherits Stream Implements ICloneable, INullable [C#] public sealed class OracleLob : Stream, ICloneable, INullable [C++] public __gc __sealed class OracleLob : public Stream, ICloneable, INullable [JScript] public class OracleLob extends Stream implements ICloneable, INullable
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Remarks
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. 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 gigabytes. 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 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 prior to obtaining a temporary LOB. Otherwise, the OracleDataReader may fail to obtain subsequent data.
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 conn = new OracleConnection("server=MyServer; integrated security=yes;");
conn.Open();
OracleTransaction tx = conn.BeginTransaction();
OracleCommand cmd = conn.CreateCommand();
cmd.Transaction = tx;
cmd.CommandText = "declare xx blob; begin dbms_lob.createtemporary(xx, false, 0); :tempblob := xx; end;";
cmd.Parameters.Add(new OracleParameter("tempblob", OracleType.Blob)).Direction = ParameterDirection.Output;
cmd.ExecuteNonQuery();
OracleLob tempLob = (OracleLob)cmd.Parameters[0].Value;
tempLob.BeginBatch(OracleLobOpenMode.ReadWrite);
tempLob.Write(tempbuff,0,tempbuff.Length);
tempLob.EndBatch();
cmd.Parameters.Clear();
cmd.CommandText = "myTable.myProc";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new OracleParameter("ImportDoc", OracleType.Blob)).Value = tempLob;
cmd.ExecuteNonQuery();
tx.Commit(); Note The inherited WriteByte method fails if used with character data, and an InvalidOperationException is thrown. Use the Write method instead.
Requirements
Namespace: System.Data.OracleClient
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
Assembly: System.Data.Oracleclient (in System.Data.Oracleclient.dll)