我自己无法弄清楚如何在我的 c# 应用程序中读取 Oracle 的脚本输出。请帮助某人。代码示例如下:
...
List<DateTime> dtList = new List<DateTime>();
using (OracleConnection connection = new OracleConnection (connectionString))
{
connection.Open ();
string sqlText = @" SET SERVEROUTPUT ON;
Declare
start_date TIMESTAMP;
return_date_after TIMESTAMP;
next_run_date TIMESTAMP;
BEGIN
start_date :=
to_timestamp_tz('01-JAN-2003 10:00:00','DD-MON-YYYY HH24:MI:SS');
return_date_after := start_date;
FOR i IN 1..5 LOOP
DBMS_SCHEDULER.EVALUATE_CALENDAR_STRING(
'freq=weekly; BYDAY=MON,TUE,WED',
start_date, return_date_after, next_run_date);
DBMS_OUTPUT.PUT_LINE('next_run_date: ' || next_run_date);
return_date_after := next_run_date;
END LOOP;
END;";
OracleCommand command = new OracleCommand (sqlText, connection);
OracleDataReader reader = command.ExecuteReader ();
while (reader.Read ())
{
dtList.Add((DateTime)reader [ "next_run_date" ]);
}
}
... But it just doesn't enter the while loop, because script output is not in rows. How can I put the following output in rows of some table or maybe read them directly from my app. Thanks
next_run_date: 06-JAN-03 10.00.00.000000 AM
next_run_date: 07-JAN-03 10.00.00.000000 AM
next_run_date: 08-JAN-03 10.00.00.000000 AM
next_run_date: 13-JAN-03 10.00.00.000000 AM
next_run_date: 14-JAN-03 10.00.00.000000 AM