执行 isb.pkg_po_test.get_component 程序,我必须从远程数据库中获取游标。
我们的架构 ISBREPORTER ,我们对架构 ibs 的访问权限有限。 但是,在Oracle SQL Plus上,以下内容执行得非常好:
SQL> var r refcursor
SQL> exec isb.pkg_po_test.get_component(15048,6,1,1,to_date('17 .12.2017'),:r);
SQL>打印;
印刷结果:
ID PRODUCT_TYPE_ID COMPONENT_ID COMPONENT_NAME
1 1 1012161 some text_1
2 1 1012160 some text_2
3 1 1012158 some text_3
4 1 10078 some text_4
5 1 10078 some text_5
6 1 10040 some text_6
7 1 1012149 some text_7
当我尝试从java代码调用它时,我得到了这个异常:
java.sql.SQLException: ORA-06550: line 1, column 7:
PLS-00201: identifier 'ISB.PKG_PO_TEST must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:450)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:399)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:1017)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:655)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:249)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:566)
at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:210)
at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:53)
at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:938)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1075)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3820)
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3923)
at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:5617)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:1385)
at org.apache.tomcat.dbcp.dbcp2.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:197)
at org.apache.tomcat.dbcp.dbcp2.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:197)
以下是我从java中调用它的方法:
public void printCursor(PrintWriter out) {
Connection ktConnection;
try {
ktConnection = ConnectionPool.getConnectionKT();
} catch (SQLException e) {
e.printStackTrace();
return;
}
String statement = "{CALL isb.pkg_po_test.get_component(?,?,?,?,?,?)}";
try {
CallableStatement call = ktConnection.prepareCall(statement);
call.setFloat(1, 15048);
call.setFloat(2, 6);
call.setFloat(3, 1);
call.setInt(4, 1);
call.setDate(5, Date.valueOf("2017-12-17"));
call.registerOutParameter(6, OracleTypes.CURSOR);
call.execute();
ResultSet rs = (ResultSet) call.getObject(6);
while (rs.next()) {
String column = rs.getString("COMPONENT_NAME");
out.print(column); //to test if it is working
}
} catch (SQLException e) {
e.printStackTrace();
}
}
从其他模式执行存储过程是否正确?如果 不,你能告诉我如何正确处理它吗?
我已阅读其他类似的问题但没有帮助。以下是其中一些: