OracleClob Class

An OracleClob is an object that has a reference to CLOB data. It provides methods for performing operations on CLOBs. Note: The OracleClob object uses the client side character set when retrieving or writing CLOB data using a .NET Framework byte array.

Class Inheritance

System.Object

System.MarshalByRefObject

System.IO.Stream

Oracle.DataAccess.Types.OracleClob

Declaration

// C#
public sealed class OracleClob : Stream, ICloneable, INullable

Requirements

Provider ODP.NET, Unmanaged Driver ODP.NET, Managed Driver ODP.NET Core
Assembly Oracle.DataAccess.dll Oracle.ManagedDataAccess.dll Oracle.ManagedDataAccess.dll
Namespace Oracle.DataAccess.Client Oracle.ManagedDataAccess.Client Oracle.ManagedDataAccess.Client
.NET Framework See System Requirements See System Requirements -
.NET (Core) - - See System Requirements

Thread Safety

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

Example

// C#

using System;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;

class OracleClobSample
{
  static void Main()
  {
    string constr = "User Id=scott;Password=tiger;Data Source=oracle";
    OracleConnection con = new OracleConnection(constr);
    con.Open();

    OracleClob clob = new OracleClob(con);

    // Write 4 chars from writeBuffer, starting at buffer offset 0
    char[] writeBuffer = new char[4] {'a', 'b', 'c', 'd'};
    clob.Write(writeBuffer, 0, 4);

    // Append first 2 chars from writeBuffer {'a', 'b'} to the oracleClob
    clob.Append(writeBuffer, 0, 2);

    // Prints "clob.Length  = 12"
    Console.WriteLine("clob.Length  = " + clob.Length);

    // Reset the Position for the Read
    clob.Position = 0;

    // Read 6 chars into readBuffer, starting at buffer offset 0
    char[] readBuffer = new char[6];
    int charsRead = clob.Read(readBuffer, 0, 6);

    // Prints "charsRead    = 6"
    Console.WriteLine("charsRead    = " + charsRead);

    // Prints "readBuffer   = abcdab"
    Console.Write("readBuffer   = ");
    for(int index = 0; index <  readBuffer.Length; index++)
    {
      Console.Write(readBuffer[index]);
    }
    Console.WriteLine();

    // Search for the 2nd occurrence of a char pattern 'ab'
    // starting from char offset 0 in the OracleClob
    char[] pattern = new char[2] {'a', 'b'};
    long posFound = clob.Search(pattern, 0, 2);

    // Prints "posFound     = 5"
    Console.WriteLine("posFound     = " + posFound);

    // Erase 4 chars of data starting at char offset 1
    // Sets chars to ''
    clob.Erase(1, 4);

    //Prints "clob.Value   = a    b"
    Console.WriteLine("clob.Value   = " + clob.Value);

    clob.Close();
    clob.Dispose();

    con.Close();
    con.Dispose();
  }
}
  <div class="infoboxnote" markdown="1">



  **See Also:**



  - "[Oracle.DataAccess.Types and Oracle.ManagedDataAccess.Types Namespaces](intro003.html#GUID-425C9EBA-CFFC-47FE-B490-604251714ACA)"



  - [OracleClob Members](ClobMembers.html#GUID-0421F9CB-C174-4273-BAE3-6D6135CFDDEB)



  - [OracleClob Constructors](ClobCtors.html#GUID-E1463875-E9B4-47E2-8B70-A5C7A396CEB5)



  - [OracleClob Static Fields](ClobStaticFields.html#GUID-93E8603C-8277-42D6-A77C-AC80975D353A)



  - [OracleClob Static Methods](ClobStaticMethods.html#GUID-1F377A7A-25E5-4C5C-8128-4F529F2A6ACD)



  - [OracleClob Instance Properties](ClobInstanceProperties.html#GUID-DA9457A1-C455-452E-8F7E-E1684F7ECBBD)



  - [OracleClob Instance Methods](ClobInstanceMethods.html#GUID-D5E1BAC5-DADA-4A90-A152-8928D52E0055)



  </div>