我有一个问题会从 Java 调用 plsql 过程。程序包如下:(模式job_runner和连接用户/方案不同):
create or replace package test_package_for_sp as
type some_record_type is record
(
field_number number,
field_varchar2 varchar2 (128),
field_date date
);
type some_table_type is table of some_record_type;
procedure proc_table (p_card_bin in varchar2,
p_date in date default null,
p_out_table out some_table_type);
}
然后我尝试使用 callableStatement 从 Java 调用它:
final String typeTableList = "SOME_TABLE_TYPE";
CallableStatement cs = null;
try (Connection con = dataSource.getConnection()) {
con.setSchema("JOB_RUNNER");
cs = con.prepareCall("{call job_runner.test_package_for_sp.proc_table(?, ?, ?)}");
cs.setString(1, "54867321");
cs.setDate(2, Date.valueOf(ZonedDateTime.now().minusDays(200).toLocalDate()));
cs.registerOutParameter(3, Types.ARRAY, typeTableList);
cs.execute();
} finally {
if (cs != null)
cs.close();
}
错误引发:
java.sql.SQLException: invalid name pattern: <connection_scheme>.SOME_TABLE_TYPE
at oracle.jdbc.oracore.OracleTypeADT.initMetadata11_2(OracleTypeADT.java:764)
at oracle.jdbc.oracore.OracleTypeADT.initMetadata(OracleTypeADT.java:479)
at oracle.jdbc.oracore.OracleTypeADT.init(OracleTypeADT.java:443)
如果我将值typeTableLis从值更改SOME_TABLE_TYPE为完整路径,并且包和方案JOB_RUNNER.TEST_PACKAGE_FOR_SP.SOME_TABLE_TYPE异常更改为:
java.sql.SQLSyntaxErrorException: ORA-01948: identifier's name length (35) exceeds maximum (30)
ORA-06512: at "SYS.DBMS_PICKLER", line 18
ORA-06512: at "SYS.DBMS_PICKLER", line 58
ORA-06512: at line 1
at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:494)
有人知道如何从java调用这个过程吗?
月关宝盒
九州编程
相关分类