1、創建一個帶輸出數據集的Oracle存儲過程
create or replace procedure PRO_test(in_top in number,cur_out out sys_refcursor) is
--查詢指定記錄條數的數據,並返回總共記錄數,返回多個數據集
begin
open cur_out for
SELECT * FROM dept_dict where rownum < in_top;
end PRO_test;
2、C#調用
Pu_Sys.GetConnObject con = new Pu_Sys.GetConnObject();
OracleConnection conn = new OracleConnection(con.Get_ConnStr());
OracleCommand Dcomm = new OracleCommand("PRO_TEST", conn);
Dcomm.CommandType = CommandType.StoredProcedure;
OracleParameter DpPass = new OracleParameter();
DpPass.Value = 5;
DpPass.Direction = System.Data.ParameterDirection.Input;
DpPass.ParameterName = "in_top";
Dcomm.Parameters.Add(DpPass);
OracleParameter DpOut = new OracleParameter("cur_out", OracleType.Cursor);
DpOut.Direction = System.Data.ParameterDirection.Output;
Dcomm.Parameters.Add(DpOut);
OracleDataAdapter Da = new OracleDataAdapter(Dcomm);
DataSet Ds = new DataSet();
try
{
Da.Fill(Ds);
}
catch (Exception)
{
}
conn.Close();
conn.Dispose();