和一般返回結果集合的存儲過程的用法一樣,只是需要加包名。
...
SqlCommand sampleCMD = new SqlCommand("Package.ProName", myConn);
sampleCMD.CommandType = CommandType.StoredProcedure;
...myConn.Open();SqlDataReader sampReader = sampleCMD.ExecuteReader();
...
...
SqlCommand sampleCMD = new SqlCommand("Package.ProName", myConn);
sampleCMD.CommandType = CommandType.StoredProcedure;
...myConn.Open();SqlDataReader sampReader = sampleCMD.ExecuteReader();
...
myConnection.Open()
Dim myCommand As New OracleCommand()
myCommand.Connection = myConnection
myCommand.CommandType = CommandType.StoredProcedure myCommand.CommandText = "packagename.procedurename" myCommand.Parameters.Add("CURSORname", OracleType.Cursor).Direction = ParameterDirection.Output Dim myReader As OracleDataReader
myReader = myCommand.ExecuteReader() ListBox2.DataSource = myReader
ListBox2.DataTextField = "PROJECTNAME"
ListBox2.DataBind()
ListBox2.SelectedIndex = 0 myReader.Close()
myConnection.Close()
myReader = Nothing
myConnection = Nothing
的存储过程的形参是要返回的游标的写法,
为什么不能编译成功呢?
create or replace package pkg_test
as
type cur_test is ref cursor; -- 定義一個cursor的type
end pkg_test;
/
create or replace procedure p_test
(
v_cur out pkg_test.cur_test
)
as
v_sql varchar2(100); --
begin
v_sql := 'select a1,a2 from test';
OPEN v_cur FOR v_sql; --
exception
when others then
DBMS_OUTPUT.PUT_LINE('Error ---------------' || sqlcode || ' : ' || sqlerrm );
end p_test;
/