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.
SQL Server过程可以返回结果集。我有一个表emp(emp__id,emp__name,...)。以下过程将返回与提供的名称相匹配的员工列表。
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.
所以在客户端代码中,要获取数据我使用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?
如何在PL / SQL中等效编码?
1 个解决方案
#1
3
Use a Ref cursor for the Stored Procedure:
http://www.oradev.com/ref_cursor.jsp
对存储过程使用Ref游标: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:
对于客户端部分,请使用Oracle数据提供程序。您可以从Oracle下载它,其语法类似于SQLDataAdapter。像这样的东西:
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);
#1
3
Use a Ref cursor for the Stored Procedure:
http://www.oradev.com/ref_cursor.jsp
对存储过程使用Ref游标: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:
对于客户端部分,请使用Oracle数据提供程序。您可以从Oracle下载它,其语法类似于SQLDataAdapter。像这样的东西:
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);