ERROR: ORA-24817 "Unable to allocate the given chunk for current lob operation" When Inserting Clob Larger Than 15 Mb (Doc ID 780248.1)

Last updated on JULY 05, 2017

Applies to:

Oracle Data Provider for .NET - Version 10.2.0.5 and later
Microsoft Windows (32-bit)
***Checked for relevance on 28-Oct-2014***

Symptoms

Executing a .NET application to insert a LOB into the database fails with:

ORA-24817: Unable to allocate the given chunk for current lob operation

In this scenario:

CLOB's are >15 MB, error occurs.
CLOB's are <15 MB, are successfully inserted into database.

 

/*
  ClobExample3.cs shows how to update a CLOB
  using the GetOracleClobForUpdate() method of an OracleDataReader
*/

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

class ClobExample3
{
  public static void Main()
  {
    // create an OracleConnection object to connect to the
    // database and open the connection
    OracleConnection myOracleConnection =
      new OracleConnection(
        "User Id=lob_user;Password=lob_password"
      );
    myOracleConnection.Open();

    // create an OracleCommand object to hold a SQL statement
    OracleCommand myOracleCommand = myOracleConnection.CreateCommand();

    // step 1: create an OracleTransaction object
    OracleTransaction myOracleTransaction =
      myOracleConnection.BeginTransaction();

    // step 2: read the row
    myOracleCommand.CommandText =
      "SELECT id, clob_column " +
      "FROM clob_content " +
      "WHERE id = 1";
    OracleDataReader myOracleDataReader =
      myOracleCommand.ExecuteReader();
    myOracleDataReader.Read();

    Console.WriteLine("myOracleDataReader[\"id\"] = " +
      myOracleDataReader["id"]);

    // step 3: get the LOB locator
    OracleClob myOracleClob =
      myOracleDataReader.GetOracleClobForUpdate(1);

    // step 4: write to the LOB
    myOracleClob.Erase();
    string text = "It is the east, and Juliet is the Sun";
    char [] charArray = text.ToCharArray();
    myOracleClob.Write(charArray, 0, charArray.Length);
    Console.WriteLine("myOracleClob.Value = " + myOracleClob.Value);

    // step 5: commit the transaction
    myOracleTransaction.Commit();
    Console.WriteLine("Successfully committed transaction");

    // close the OracleDataReader and the OracleConnection object
    myOracleDataReader.Close();
    myOracleConnection.Close();

    Console.WriteLine("\nPress any key to end");
    Console.ReadLine();
  }
}

 

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms