日本語PDF

Search

このインスタンス・メソッドでは、OracleBlobの現行インスタンスのバイナリ・パターンを検索します。

宣言

// C#
public Int64 Search(byte[] val, int64 offset, int64 nth);

パラメータ

  • val

    検索対象のバイナリ・パターン

  • offset

    OracleBlobの検索が開始される0ベース・オフセット(バイト)

  • nth

    絶対オフセット(バイト)が戻される特定の一致状況の発生(1ベース)

戻り値

一致のnth回目の出現に対して、一致パターン(バイト表示)の起点の絶対offsetを戻します。それ以外の場合は、0が戻されます。

例外

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

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

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

  • offset0未満の場合

  • nth0以下の場合

  • val.Length16383より大きい場合

  • nthOracleBlob.MaxSize以上の場合

  • offsetOracleBlob.MaxSize以上の場合

備考

検索パターンの制限は16383バイトです。

// C#
 
using System;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
 
class SearchSample
{
  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);
      
    // Write 7 bytes, starting at buffer offset 0
    byte[] buffer = new byte[7] {1, 2, 3, 4, 1, 2, 3};
    blob.Write(buffer, 0, 7);
      
    // Search for the 2nd occurrence of a byte pattern '23'
    // starting at offset 1 in the OracleBlob
    byte[] pattern = new byte[2] {2 ,3};
    long posFound = blob.Search(pattern, 1, 2);
 
    // Prints "posFound = 6" 
    Console.WriteLine("posFound = " + posFound);
 
    blob.Close();
    blob.Dispose();
 
    con.Close();
    con.Dispose();
  }
}