[英]method Name execute This statement does not declare an OUT parameter. Use { ?= call ... } to declare one
I had migrated database from Oracle to AWS Aurora PostgreSQL.我已将数据库从 Oracle 迁移到 AWS Aurora PostgreSQL。 I saw that all the packages are migrated as Function in PostgreSQL.
我看到所有的包都被迁移为 PostgreSQL 中的函数。 I used AWS SCT for the Oracle schema conversion to postgreSQL.
我使用 AWS SCT 将 Oracle 模式转换为 postgreSQL。 Java is the application middleware.
Java是应用程序中间件。
for example, A package and associated stored proc in Oracle pk_audit.sp_get_audit
converted to postgreSQL as pk_audit$sp_get_audit
with a $
symbol.例如,Oracle
pk_audit.sp_get_audit
包和关联的存储pk_audit.sp_get_audit
转换为 postgreSQL 为pk_audit$sp_get_audit
并带有$
符号。
When I run the web application, I'm getting an error like method Name execute This statement does not declare an OUT parameter.当我运行 Web 应用程序时,我收到一个错误,如方法名称执行此语句未声明 OUT 参数。 Use { ?= call ... } to declare one .
使用 { ?= call ... } 声明一个。
I don't have access to the application, but App team provided weblogic log.我无权访问该应用程序,但 App 团队提供了 weblogic 日志。 It says,
它说,
Method Name execute org.postgresql.util.PSQLException: This statement does not declare an OUT parameter.Use { ?= call ... } to declare one. org.postgresql.jdbc.PgCallableStatement.registerOutParameter(PgCallableStatement.java:205) weblogic.jdbc.wrapper.CallableStatement_org_postgresql_jdbc_PgCallableStatement.registerOutParameter(Unknown Source
package name specified in the Java code is pk_audit.sp_get_audit
Renamed the Postgres function pk_audit$sp_get_audit
to pk_audit.sp_get_audit
still facing the issue. Java 代码中指定的包名称为
pk_audit.sp_get_audit
将 Postgres 函数pk_audit$sp_get_audit
重命名为pk_audit.sp_get_audit
仍然面临问题。
Is there anything I need to do in PostgreSQL DB ?我需要在 PostgreSQL DB 中做什么吗? I need advise and help,Thanks.
我需要建议和帮助,谢谢。
As documented in CallableStatement
, the JDBC syntax for calling stored procedures is one of these如
CallableStatement
,用于调用存储过程的 JDBC 语法是其中之一
{call ProcedureName(?, ...)}
{? = call FunctionName(?, ...)}
Any of the parameters can be OUT parameters.任何参数都可以是 OUT 参数。 The return value is of course a type of OUT parameter.
返回值当然是一种 OUT 参数。
So, if you had a stored procedure with 2 parameters and the second parameter was an OUT parameter, you would code it as:因此,如果您有一个带有 2 个参数的存储过程,而第二个参数是一个 OUT 参数,您可以将其编码为:
String sql = "{call MyProcedure(?, ?)}";
try (CallableStatement stmt = conn.prepareCall(sql)) {
stmt.setInt(1, p1);
stmt.registerOutParameter(2, Types.VARCHAR);
...
}
If that same procedure is converted into a function, you would code it as:如果将相同的过程转换为函数,您可以将其编码为:
String sql = "{? = call MyFunction(?)}";
try (CallableStatement stmt = conn.prepareCall(sql)) {
stmt.registerOutParameter(1, Types.VARCHAR);
stmt.setInt(2, p1);
...
}
If you cannot change the Java code making the call, you need to convert your functions back to procedures.如果无法更改进行调用的 Java 代码,则需要将函数转换回过程。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.