我有一个存储功能设置如下:
CREATE OR REPLACE PACKAGE PACKAGENAME IS
FUNCTION READ_FUNC(i_name IN VARCHAR2)
RETURN SYS_REFCURSOR;
END PACKAGENAME;
/
CREATE OR REPLACE PACKAGE BODY PACKAGENAME AS
FUNCTION
READ_FUNC(i_name IN VARCHAR2)
RETURN SYS_REFCURSOR
IS
cursor SYS_REFCURSOR;
BEGIN
//do stuff
RETURN cursor;
END READ_FUNC;
我试图按以下方式在Java中调用它,但我却得到
not a valid function or procedure name
try(CallableStatement stmt = conn.prepareCall("call PACKAGENAME.READ_FUNC(?)")
{
stmt.setString(1, name);
ResultSet result = stmt.executeQuery();
// do stuff with result
}
它肯定存在是因为我可以
desc PACKAGENAME
并且它具有我的功能。我还可以调用其他程序。有人知道我在做什么错吗? 最佳答案
请尝试以下操作:
CallableStatement stmt = conn.prepareCall("{ ? = call PACKAGENAME.READ_FUNC(?) }");
stmt.registerOutParameter(1, OracleTypes.CURSOR);
stmt.setString(2, name);
关于java - java-调用返回游标的存储函数,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32252982/