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

前
次

Search(char[ ], Int64, Int64)

このインスタンス・メソッドでは、OracleClobの現行インスタンスの文字パターンを検索します。

宣言

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

パラメータ

  • val

    検索対象のUnicode文字列

  • offset

    OracleClobの検索の起点の0ベース・オフセット(文字)

  • nth

    絶対オフセット(文字)が戻される特定の一致の出現(1ベース)

戻り値

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

例外

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

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

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

  • offset0未満の場合

  • nth0以下の場合

  • val.Lengthの2倍が16383より大きい場合

  • nthOracleClob.MaxSize以上の場合

  • offsetOracleClob.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();
 
    OracleClob clob = new OracleClob(con);
    
    // Write 7 chars, starting at buffer offset 0
    char[] buffer = new char[7] {'a', 'b', 'c', 'd', 'a', 'b', 'c'};
    clob.Write(buffer, 0, 7);
      
    // Search for the 2nd occurrence of a char pattern 'bc'
    // starting at offset 1 in the OracleBlob
    char[] pattern = new char[2] {'b', 'c'};
    long posFound = clob.Search(pattern, 1, 2);
 
    // Prints "posFound = 6" 
    Console.WriteLine("posFound = " + posFound);
          
    clob.Close();
    clob.Dispose();
 
    con.Close();
    con.Dispose();
  }
}