| Oracle® Data Provider for .NET開発者ガイド ODAC 12.2c リリース1 (12.2.0.1) for Microsoft Windows E88311-03 |
|
![]() 前 |
![]() 次 |
このインスタンス・メソッドでは、2つのOracleBFileが参照するデータを比較します。
宣言
// C# public int Compare(Int64 src_offset, OracleBFile obj, Int64 dst_offset, Int64 amount);
パラメータ
src_offset
現行インスタンスのオフセット
obj
指定されたOracleBFileオブジェクト
dst_offset
OracleBFileオブジェクトのオフセット
amount
比較するバイト数
戻り値
次の数を戻します。
ゼロ未満: 現行のインスタンスのBFILEデータが指定されたBFILEデータの値より小さい場合。
ゼロ:どちらのBFILEにも同じデータが格納されている場合
ゼロ超過: 現行のインスタンスのBFILEデータが指定されたBFILEデータの値より大きい場合。
例外
ObjectDisposedException - オブジェクトはすでに処理されています。
InvalidOperationException - OracleConnectionがオープンされていないか、またはオブジェクトの存続中にクローズされています。
ArgumentOutOfRangeException - src_offset、dst_offsetまたはamountが0より小さい場合。
備考
指定されたオブジェクトと現行のインスタンスには、同じ接続を使用する必要があります。つまり、同じOracleConnectionオブジェクトを使用します。
BFILEは、操作前にOpenFileを使用してオープンされている必要があります。
例
// 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 CompareSample
{
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 bFile1 = new OracleBFile(con, "MYDIR", "MyFile.txt");
OracleBFile bFile2 = new OracleBFile(con, "MYDIR", "MyFile.txt");
// Open the OracleBFiles
bFile1.OpenFile();
bFile2.OpenFile();
// Compare 2 bytes from the 1st byte of bFile1 and
// the 5th byte of bFile2 onwards
int result = bFile1.Compare(1, bFile2, 5, 2);
// Prints "result = 0" (Indicates the data is identical)
Console.WriteLine("result = " + result);
// Close the OracleBFiles
bFile1.CloseFile();
bFile2.CloseFile();
bFile1.Close();
bFile1.Dispose();
bFile2.Close();
bFile2.Dispose();
con.Close();
con.Dispose();
}
}