I'm trying to improve performance of my Oracle SQL queries by using array binding to an OracleParameter.
This is basically what I'm trying to do:
List<string> IDValList = new List<string>();
IDValList.Add( "IDOne" );
IDValList.Add( "IDTwo" );
List<int> sizes = new List<int>();
foreach( string id in IDValList )
{
sizes.Add( id.Length );
}
using( OracleCommand cmd = new OracleCommand( "select col1, col2, col3 from table where col4 in ( :idArray )", _conn ) )
{
cmd.CommandType = System.Data.CommandType.Text;
OracleParameter arrayParam = new OracleParameter( "idArray", OracleDbType.Varchar2 );
arrayParam.Direction = System.Data.ParameterDirection.Input;
arrayParam.Value = IDValList.ToArray();
arrayParam.ArrayBindSize = sizes.ToArray();
cmd.ArrayBindCount = IDValList.Count;
cmd.Parameters.Add( arrayParam );
using( OracleDataReader dr = cmd.ExecuteReader() )
{
while( dr.Read() )
{
// now read the row...
This compiles and runs, but I always only get back one row, for the first ID. Its like its ignoring the rest of the values in the array in the parameter.
Interestingly enough, the ArrayBindStatus of the parameter is successful for all the values.
What am I missing? Or will this not work with an OracleReader?
Thanks
Edit: Basically, I'm trying to follow this example, but I want to be able to read the resulting dataset from the query using a DataReader.
http://www.oracle.com/technology/oramag/oracle/09-sep/o59odpnet.html