我创建了一个包:
create or replace PACKAGE merc
AS
TYPE resultcurtyp is REF CURSOR;
END merc;
然后是存储过程:
create or replace PROCEDURE merc_results
(
testP IN VARCHAR2 DEFAULT NULL,
CURSOR_ IN OUT merc.resultcurtyp
) AS
BEGIN
OPEN CURSOR_ FOR
SELECT /*csv*/
FR.*
FROM DS.table1 FR
INNER JOIN DS.price PN ON PN.OBJECTID = FR.SOURCEID
WHERE FR.NAME = testP
END merc_results;
调用Stored proc表单.Net代码给我:
ORA-06550: line 1, column 15:
PLS-00222: no function with name 'merc' exists in this scope
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
我是否需要创建包,从中调用存储,然后从.Net调用包?我现在直接从代码调用存储过程。 我之前没有使用过oracle db。
答案 0 :(得分:0)
在c#中:
OracleCommand cmd = new OracleCommand("yourshema.merc.merc_results", Connection);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("testP", testP);
cmd.Parameters.Add("CURSOR_", OracleDbType.RefCursor).Direction = ParameterDirection.Output;
OracleDataAdapter da = new OracleDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
return ds;
Oracle Package:
CREATE OR REPLACE PACKAGE merc
IS
TYPE resultcurtyp IS REF CURSOR;
PROCEDURE merc_results(
testP IN VARCHAR2 DEFAULT NULL,
CURSOR_ OUT resultcurtyp );
END;
/
CREATE OR REPLACE PACKAGE BODY merc
IS
PROCEDURE merc_results(
testP IN VARCHAR2 DEFAULT NULL,
CURSOR_ OUT resultcurtyp )
AS
BEGIN
OPEN CURSOR_ FOR SELECT
FR.* FROM DS.table1 FR INNER JOIN DS.price PN ON PN.OBJECTID = FR.SOURCEID WHERE FR.NAME = testP;
END merc_results;
END merc;
/