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

前
次

Search

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

宣言

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

パラメータ

  • val

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

  • offset

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

  • nth

    オフセットが戻される特定の一致の状態(1ベース)

戻り値

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

例外

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

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

ArgumentOutOfRangeException - offset0未満の場合、nth0以下の場合、val.Length16383より大きい場合、nthOracleBFile.MaxSize以上の場合またはoffsetOracleBFile.MaxSize以上の場合のいずれか。

備考

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

// Database Setup, if you have not done so yet.
/* Log on as DBA (SYS or SYSTEM) that has CREATE ANY DIRECTORY privilege.
 
CREATE OR REPLACE DIRECTORY MYDIR AS 'C:\TEMP';
 
*/
 
// C#
 
using System;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
 
class SearchSample
{
  static void Main()
  {
    // Create MYDIR directory object as indicated previously and create a file
    // MyFile.txt with the text ABCDABC under C:\TEMP directory.
    // Note that the byte representation of the ABCDABC is 65666768656667
 
    string constr = "User Id=scott;Password=tiger;Data Source=oracle";
    OracleConnection con = new OracleConnection(constr);
    con.Open();
 
    OracleBFile bFile = new OracleBFile(con, "MYDIR", "MyFile.txt");
 
    // Open the OracleBFile
    bFile.OpenFile();
    
    // Search for the 2nd occurrence of a byte pattern {66,67}
    // starting from byte offset 1 in the OracleBFile
    byte[] pattern = new byte[2] {66, 67};
    long posFound = bFile.Search(pattern, 1, 2);
    
    // Prints "posFound = 6" 
    Console.WriteLine("posFound = " + posFound);
    
    // Close the OracleBFile
    bFile.CloseFile();
 
    bFile.Close();
    bFile.Dispose();
 
    con.Close();
    con.Dispose();
  }
}