ulong
(つまり、UInt64
) 番号を Oracle データベースに挿入する必要がありますが、 ArgumentException
. 私はそれをNUMBER
列に挿入しています.0から2 ^ 64-1までの任意の数値を格納できるはずです.
エラーを再現する最小限の例を次に示します。
// First create the following table:
//
// CREATE TABLE SampleTable (SampleColumn NUMBER)
//
using (var dbConnection = new OracleConnection("..."))
{
ulong valueToInsert = 123;
OracleCommand command = dbConnection.CreateCommand();
command.CommandText = @"INSERT INTO SampleTable (SampleColumn) VALUES (:SampleColumn)";
command.Parameters.Add("SampleColumn", valueToInsert);
command.ExecuteNonQuery();
}
このコードvalueToInsert
は、他の整数型 ( を含むlong
) であれば問題なく動作しますが、 で試してみるとulong
、次のエラーが発生します。
System.ArgumentException was unhandled by user code
HResult=-2147024809
Message=Value does not fall within the expected range.
Source=Oracle.DataAccess
StackTrace:
at Oracle.DataAccess.Client.OracleParameter..ctor(String parameterName, Object obj)
at Oracle.DataAccess.Client.OracleParameterCollection.Add(String name, Object val)
なぜこうなった?
PS私はOracle.DataAccess 2.112.1.2とOracle.ManagedDataAccess 4.212.1.0の両方を使用してみました。