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 the name provided.
CREATE OR REPLACE PROCEDURE get_employee_by_name ( @name VARCHAR(100) ) AS SELECT emp_id, emp_name FROM emp WHERE emp_name = @name;
So in the client code, to get the data I use ADO.NET.
SQLDataAdapter adapter = new SQLDataAdapter('get_employee_by_name', cnString); SQLDataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure; DataTable dt = new DataTable('employee'); adapter.Fill(dt);
How can I code equivalently in PL/SQL?
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: