日本語PDF

Write

Streamをオーバーライドします

このインスタンス・メソッドでは、指定されたバッファをOracleBlobに書き込みます。

宣言

// C#
public override void Write(byte[ ] buffer, int offset, int count);

パラメータ

  • buffer

    データを指定するバイト配列buffer

  • offset

    bufferの読取りが開始される0ベース・オフセット(バイト)

  • count

    OracleBlobに書き込まれるデータ量(バイト)

例外

ObjectDisposedException - オブジェクトはすでに処理されています。

InvalidOperationException - OracleConnectionがオープンされていないか、またはオブジェクトの存続中にクローズされています。

ArgumentOutOfRangeException - この例外は次のいずれかの条件が存在する場合に表示されます。

  • offsetまたはcount0未満の場合

  • offsetbuffer.Length以上である場合

  • offsetおよびcountの合計がbuffer.Lengthより大きい場合

備考

OracleBloboffset先はPositionプロパティで指定できます。

// C#
 
using System;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
 
class WriteSample
{
  static void Main()
  {
    string constr = "User Id=scott;Password=tiger;Data Source=oracle";
    OracleConnection con = new OracleConnection(constr);
    con.Open();
 
    OracleBlob blob = new OracleBlob(con);
    
    // Set the Position for the Write
    blob.Position = 0;  
 
    // Begin ChunkWrite to improve performance
    // Index updates occur only once after EndChunkWrite
    blob.BeginChunkWrite();
          
    // Write to the OracleBlob in 5 chunks of 2 bytes each
    byte[] b = new byte[2] {1, 2};
    for(int index = 0; index < 5; index++)
    {
      blob.Write(b, 0, b.Length);
    }
    blob.EndChunkWrite();
 
    byte[] chunkBuffer = blob.Value;
 
    // Prints "chunkBuffer = 1212121212"
    Console.Write("chunkBuffer = ");
    for(int index = 0; index < chunkBuffer.Length; index++)
    {
      Console.Write(chunkBuffer[index]);
    }
    Console.WriteLine();
 
    blob.Close();
    blob.Dispose();
 
    con.Close();
    con.Dispose();
  }
}