以下代码执行该过程根据结果集创建 DataReader并将 DataReader 的内容输出到控制台
// create connection
OracleConnection conn = new OracleConnection(Data Source=oracledb;
User Id=UserID;Password=Password;);
// create the command for the stored procedure
OracleCommand cmd = new OracleCommand();
cmdConnection = conn;
cmdCommandText = SELECT_JOB_HISTORYGetJobHistoryByEmployeeId;
cmdCommandType = CommandTypeStoredProcedure;
// add the parameters for the stored procedure including the REF CURSOR
// to retrieve the result set
cmdParametersAdd(p_employee_id OracleTypeNumber)Value = ;
cmdParametersAdd(cur_JobHistory OracleTypeCursor)Direction =
ParameterDirectionOutput;
// open the connection and create the DataReader
connOpen();
OracleDataReader dr = cmdExecuteReader();
// output the results and close the connection
while(drRead())
{
for(int i = ; i <drFieldCount; i++)
ConsoleWrite(dr[i]ToString() + ;);
ConsoleWriteLine();
}
connClose();
[] [] [] [] [] [] [] []