简体   繁体   English

方法名称 execute 该语句不声明 OUT 参数。 使用 { ?= call ... } 声明一个

[英]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 theseCallableStatement ,用于调用存储过程的 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.

相关问题 Eclipse快捷方式将变量名称声明为方法参数 - Eclipse shortcut to declare a variable name as method parameter 枚举声明调用方法 - enum declare method for call 通过Java类声明OUT参数 - Declare an OUT parameter through Java class 如何在Java中使用保留关键字声明参数名称 - How to declare a parameter name with a reserved keyword in Java 根据方法参数声明类的泛型 - Declare Generic Type for class based on method parameter 如何将方法参数声明为任何枚举 - How to declare a method parameter as any enum 如何调用和声明带有可变数量参数的方法? - How to call and declare a method with a variable amount of arguments? 我该怎么做呢? 添加一种方法一次添加一种成分(使用单个String变量作为参数。不要将其传递给数组) - How do I do this? Add a method to add one ingredient at a time (use a single String variable as the parameter. Do not pass it an array) 此方法调用为非空方法参数传递空值。 将该参数注释为应始终为非null的参数 - This method call passes a null value for a nonnull method parameter. Either the parameter is annotated as a parameter that should always be nonnull 如何声明和调用从RPG获取二维bye数组参数的java方法? - How to declare and call a java method which takes two dimensional bye array parameter from RPG?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM