How to make Oracle procedure return result sets

后端 未结 1 1239
予麋鹿
予麋鹿 2021-01-25 08:20

SQL Server procedure can return result sets. I have a table emp(emp__id, emp__name, ...). The procedure below will return a list of employees that matched with

相关标签:
1条回答
  • 2021-01-25 09:10

    Use a Ref cursor for the Stored Procedure:
    http://www.oradev.com/ref_cursor.jsp

    For the client part use the Oracle Data Provider. You can download it from Oracle and the syntax is similar to the SQLDataAdapter. Something like this:

    OracleDataAdapter da = new OracleDataAdapter();
    da.SelectCommand = new OracleCommand("get_employee_by_name", Connection);
    OracleParameter prm = da.SelectCommand.Parameters.Add("pName", OracleDbType.VarChar2);
    prm.Direction = ParameterDirection.Input;
    prm.Value = "MyName";
    prm = da.SelectCommand.Parameters.Add("pResult", OracleDbType.RefCursor);
    prm.Direction = ParameterDirection.Output;
    DataTable dt = new DataTable();
    da.Fill(dt);
    
    0 讨论(0)
提交回复
热议问题