WriteAsync

WriteAsync returns a Task-based asynchronous version of OracleClob.Write(), which reads a specified number of bytes from the ODP.NET LOB instance and populates the buffer.

Overload List:

  • WriteAsync(byte[], int, int)

    WriteAsync returns a Task-based asynchronous version of OracleClob.Write(), which reads a specified number of bytes from the ODP.NET LOB instance and populates the buffer.

  • WriteAsync(byte[], int, int, CancellationToken)

    WriteAsync returns a Task-based asynchronous version of OracleClob.Write(), which reads a specified number of bytes from the ODP.NET LOB instance and populates the buffer.

  • WriteAsync(char[], int, int)

    WriteAsync returns a Task-based asynchronous version of OracleClob.Write(), which reads a specified number of bytes from the ODP.NET LOB instance and populates the buffer.

  • WriteAsync(char[], int, int, CancellationToken)

    WriteAsync returns a Task-based asynchronous version of OracleClob.Write(), which reads a specified number of bytes from the ODP.NET LOB instance and populates the buffer.

Example (includes all overloads)

using Oracle.ManagedDataAccess.Client;
using Oracle.ManagedDataAccess.Types;
using System;
using System.Threading;
using System.Threading.Tasks;

namespace AsyncApp
{
  class AsyncDemo
  {
    static async Task Main(string[] args)
    {
      string connectionString = "User Id=HR; Password=<PASSWORD>; Data Source=oracle;";

      OracleConnection oc = new OracleConnection(connectionString);
      await oc.OpenAsync(CancellationToken.None);

      OracleClob clob = new OracleClob(oc);

      char[] writeBufferChar = new char[4] {'a', 'b', 'c', 'd'};
      byte[] writeBufferByte = new byte[4] {1, 2, 3, 4};

      //Write data to Character Large Object, asynchronously
      await clob.WriteAsync(writeBufferByte, 0, 4);
      Console.WriteLine("clob.Length  = " + clob.Length);

      //Write data to Character Large Object, asynchronously
      await clob.WriteAsync(writeBufferByte, 0, 4, CancellationToken.None);
      Console.WriteLine("clob.Length  = " + clob.Length);

      //Write data to Character Large Object, asynchronously
      await clob.WriteAsync(writeBufferChar, 0, 4);
      Console.WriteLine("clob.Length  = " + clob.Length);

      //Write data to Character Large Object, asynchronously
      await clob.WriteAsync(writeBufferChar, 0, 4, CancellationToken.None);
      Console.WriteLine("clob.Length  = " + clob.Length);
    }
  }
}