プライマリ・コンテンツに移動
Oracle® Data Provider for .NET開発者ガイド
ODAC 12.2c リリース1 (12.2.0.1) for Microsoft Windows
E88311-03
目次へ移動
目次
索引へ移動
索引

前
次

Read(char[ ], int, int)

このインスタンス・メソッドでは、現行のインスタンスから指定バイト数を読み取り、文字配列バッファに移入します。

宣言

// C#
public int Read(char[ ] buffer, int offset, int count);

パラメータ

  • buffer

    移入される文字配列バッファ

  • offset

    バッファに移入されるオフセット(文字)

  • count

    読み取られる文字数

戻り値

戻り値はCLOBから読み取られる文字数を示します。

例外

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

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

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

  • offsetまたはcount0未満の場合

  • offsetbuffer.Length以上である場合

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

備考

すべてのCLOBおよびNCLOBデータをUnicodeとして処理します。

LOBデータの読取りは、Positionプロパティにより指定された位置から開始されます。

// C#
 
using System;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
 
class ReadSample
{
  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 3 chars, starting at buffer offset 1
    char[] writeBuffer = new char[4] {'a', 'b', 'c', 'd'};
    clob.Write(writeBuffer, 1, 3);
 
    // Reset the Position (in bytes) for Read
    clob.Position = 2;
 
    // Read 2 chars into buffer starting at buffer offset 1
    char[] readBuffer = new char[4];    
    int charsRead = clob.Read(readBuffer, 1, 2);
 
    // Prints "charsRead  = 2"
    Console.WriteLine("charsRead  = " + charsRead);    
 
    // Prints "readBuffer =  cd "
    Console.Write("readBuffer = ");
    for(int index = 0; index <  readBuffer.Length; index++)
    {
      Console.Write(readBuffer[index]);
    }
    Console.WriteLine();
    
    clob.Close();
    clob.Dispose();
 
    con.Close();
    con.Dispose();
  }
}