페이지

2012년 6월 24일 일요일

Oracle Array Binding

출처 : http://www.c-sharpcorner.com/UploadFile/ramamohang/OracleDataProviderfor.NET612012005043401AM/OracleDataProviderfor.NET6.aspx



Array BindingThe array bind feature enables applications to bind arrays of a type using the OracleParameter class. Using the array bind feature, an application can insert multiple rows into a table in a single database round-trip. The following code example inserts three rows into the Dept table with a single database round-trip. The OracleCommand ArrayBindCount property defines the number of elements of the array to use when executing the statement. 

// C#

... // Create an array of values that need to be inserted int[] myArrayDeptNo = new int[3]{10, 20, 30}; // Set the command text on an OracleCommand object cmd.CommandText = "insert into dept(deptno) values (:deptno)"; // Set the ArrayBindCount to indicate the number of values cmd.ArrayBindCount = 3; // Create a parameter for the array operations OracleParameter prm = new OracleParameter("deptno", OracleDbType.Int32); 
prm.Direction = ParameterDirection.Input; 
prm.Value = myArrayDeptNo; 
// Add the parameter to the parameter collection cmd.Parameters.Add(prm); // Execute the command cmd.ExecuteNonQuery();

댓글 없음:

댓글 쓰기