如何在jdbc中检索记录%type的表。当我运行Java代码时,我得到ORA-04043:对象“ PERSON_TB”不存在。
软件包已成功编译:
CREATE OR REPLACE PACKAGE MYPKG AS
TYPE personrec IS RECORD(
id VARCHAR2(10));
type_person_rec personrec;
TYPE person_tb IS TABLE OF type_person_rec%TYPE;
PROCEDURE callproc(persondata OUT person_tb);
END MYPKG;
/
CREATE OR REPLACE PACKAGE BODY MYPKG AS
PROCEDURE callproc(persondata OUT person_tb) AS
lv_persondata person_tb;
BEGIN
lv_persondata(1).id := '123';
persondata := lv_persondata;
lv_persondata.DELETE;
END callproc;
END MYPKG;
下面是获取参数的Java代码:
String sql = "{call mypkg.callproc(?)}";
stmt = conn.prepareCall(sql);
stmt.registerOutParameter(1, java.sql.Types.ARRAY,"PERSON_TB");
stmt.execute();
这是我得到的错误:
java.sql.SQLSyntaxErrorException: ORA-04043: object "PERSON_TB" does not exist
at oracle.jdbc.driver.T2CConnection.checkError(T2CConnection.java:777)
at oracle.jdbc.driver.T2CConnection.checkError(T2CConnection.java:673)
at oracle.jdbc.driver.T2CConnection.getTdoCState(T2CConnection.java:876)
at oracle.jdbc.oracore.OracleTypeADT.initMetadata(OracleTypeADT.java:523)
at oracle.jdbc.oracore.OracleTypeADT.init(OracleTypeADT.java:471)
at oracle.sql.ArrayDescriptor.initPickler(ArrayDescriptor.java:1627)
at oracle.sql.ArrayDescriptor.<init>(ArrayDescriptor.java:243)
at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:154)
at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:123)
at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:106)
at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:73)
at oracle.jdbc.driver.NamedTypeAccessor.otypeFromName(NamedTypeAccessor.java:84)
at oracle.jdbc.driver.TypeAccessor.initMetadata(TypeAccessor.java:90)
at oracle.jdbc.driver.OracleStatement.allocateAccessor(OracleStatement.java:2458)
at oracle.jdbc.driver.T2CCallableStatement.allocateAccessor(T2CCallableStatement.java:1562)
at oracle.jdbc.driver.T2CCallableStatement.registerOutParameterInternal(T2CCallableStatement.java:1921)
at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:223)
at oracle.jdbc.driver.OracleCallableStatementWrapper.registerOutParameter(OracleCallableStatementWrapper.java:1595)
尝试在注册调用中使用MYPKG.PERSON_TB,或将类型声明移出软件包