6.19.4.1 ArrayBindSize
このプロパティは、データベースに送信する、またはデータベースから送信される、各配列要素のデータの最大サイズを、バイト数または文字数で指定します。このプロパティは、配列バインドまたはPL/SQL連想配列の実行に使用されます。
宣言
// C# public int[] ArrayBindSize {get; set; }
プロパティ値
サイズを指定する整数の配列
備考
デフォルト = null
。
このプロパティは、配列バインドまたはPL/SQL連想配列の可変サイズの要素タイプにのみ使用されます。固定サイズの要素タイプでは、このプロパティは無視されます。
ArrayBindSize
の各要素は、Value
プロパティの要素のバインド・サイズに対応しています。実行前は、ArrayBindSize
により、Value
プロパティにバインドされる各要素の最大サイズが指定されています。実行後は、Value
プロパティに戻された各要素のサイズが含まれます。
PL/SQL連想配列のバインドの場合、要素は可変長の要素タイプであり、このプロパティはInputOutput
、Out
、またはReturnValue
パラメータとして適切に設定する必要があります。ArrayBindSize
の要素数は、OracleParameter.Size
プロパティで指定されている値と同じである必要があります。
例
// C# using System; using System.Data; using Oracle.DataAccess.Client; class ArrayBindSizeSample { static void Main() { string constr = "User Id=scott;Password=tiger;Data Source=oracle"; OracleConnection con = new OracleConnection(constr); con.Open(); OracleParameter[] prm = new OracleParameter[3]; // Create OracleParameter objects through OracleParameterCollection OracleCommand cmd = con.CreateCommand(); cmd.CommandText = "select max(empno) from emp"; int maxno = int.Parse(cmd.ExecuteScalar().ToString()); // Set the ArrayBindCount for Array Binding cmd.ArrayBindCount = 2; prm[0] = cmd.Parameters.Add("paramEmpno", OracleDbType.Decimal, new int[2] {maxno + 10, maxno + 11}, ParameterDirection.Input); prm[1] = cmd.Parameters.Add("paramEname", OracleDbType.Varchar2, new string[2] {"Client1xxx", "Client2xxx"}, ParameterDirection.Input); prm[2] = cmd.Parameters.Add("paramDeptNo", OracleDbType.Decimal, new int[2] {10, 10}, ParameterDirection.Input); // Set the ArrayBindSize for prm[1] // These sizes indicate the maximum size of the elements in Value property prm[1].ArrayBindSize = new int[2]; prm[1].ArrayBindSize[0] = 7; // Set ename = "Client1" prm[1].ArrayBindSize[1] = 7; // Set ename = "Client2" cmd.CommandText = "insert into emp(empno, ename, deptno) values(:1, :2, :3)"; cmd.ExecuteNonQuery(); Console.WriteLine("Record for employee id {0} has been inserted.", maxno + 10); Console.WriteLine("Record for employee id {0} has been inserted.", maxno + 11); prm[0].Dispose(); prm[1].Dispose(); prm[2].Dispose(); cmd.Dispose(); con.Close(); con.Dispose(); } }