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();
}
}