Code: Select all
OracleCommand cmd = new OracleCommand();
string cmdText = "begin open :cur for select * from myTable; end;";
cmd.CommandText = cmdText;
cmd.Connection = connection;
cmd.Parameters.Add( "cur", OracleDbType.Cursor ).Direction = System.Data.ParameterDirection.ReturnValue;
cmd.ExecuteNonQuery();
OracleCursor oraCursor = (OracleCursor)cmd.Parameters["cur"].Value;
OracleDataReader dr = oraCursor.GetDataReader();
for ( int i = 0; i < 10000; i++ )
{
dr.Read();
for ( int j = 0; j < dr.FieldCount; j++ )
{
Console.Write( dr[j].ToString() + ";" );
}
Console.WriteLine();
}
When I use this Datareader to get the data it works with a table that doesn't contain too many entries. When I reach something like the 2540th line of the data table, however, I get an OracleException saying "OCI invalid handle".
What's wrong? (The same thing works fine with other data providers.)