oracle 在另一个 Java 存储过程中调用 Java 存储过程时出现“参数类型冲突”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2585550/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 20:22:10  来源:igfitidea点击:

"Parameter type conflict" when calling Java Stored Procedure within another Java Stored Procedure

javaoraclejdeveloper

提问by GuiPereira

Here's the problem (sorry for the bad english):

这是问题所在(抱歉英语不好):

i'm working with JDeveloper and Oracle10g, and i have a Java Stored Procedure that is calling another JSP like the code:

我正在使用 JDeveloper 和 Oracle10g,并且我有一个 Java 存储过程,它正在调用另一个 JSP,如代码:

int sd = 0;

try {
  CallableStatement clstAddRel = conn.prepareCall(" {call FC_RJS_INCLUIR_RELACAO_PRODCAT(?,?)} ");
  clstAddRel.registerOutParameter(1, Types.INTEGER);
  clstAddRel.setString(1, Integer.toString(id_produto_interno));
  clstAddRel.setString(2, ac[i].toString());
  clstAddRel.execute();

  sd = clstAddRel.getInt(1);
} catch(SQLException e) {
  String sqlTeste3 = "insert into ateste values (SQ_ATESTE.nextval, ?)";

   PreparedStatement pstTeste3 = conn.prepareStatement(sqlTeste3);
   pstTeste3.setString(1,"erro: "+e.getMessage()+ ac[i]);
   pstTeste3.execute();
   pstTeste3.close();
}

I'm recording the error in a table called ATESTE because this JavaSP is a procedure and not a function, I've to manipulate DML inside.

我正在一个名为 ATESTE 的表中记录错误,因为这个 JavaSP 是一个过程而不是一个函数,我必须在里面操作 DML。

So, the error message I'm getting is: 'parameter type conflict'...

因此,我收到的错误消息是:“参数类型冲突”...

the function "FC_RJS_INCLUIR_RELACAO_PRODCAT" it's a Java Stored Procedure too, it's already exported to Oracle, and returns an int variable, and i have to read this to decide which webservice i will call from this JavaSP.

函数“FC_RJS_INCLUIR_RELACAO_PRODCAT”也是一个 Java 存储过程,它已经导出到 Oracle,并返回一个 int 变量,我必须阅读它来决定我将从这个 JavaSP 调用哪个 web 服务。

I have already tried the OracleTyep.NUMBER in the registerOutParameter.

我已经在 registerOutParameter 中尝试了 OracleTyep.NUMBER。

Anyone knows what i'm doing wrong?

有谁知道我做错了什么?

回答by Doug Porter

It looks like you are missing a parameter in your call. You register an Integer output parameter, and then you set 2 string parameters. I'm presuming your procedure FC_RJS_INCLUIR_RELACAO_PRODCATreturns an integer value. If so your code should look more like this:

您的通话中似乎缺少一个参数。您注册一个整数输出参数,然后设置 2 个字符串参数。我假设你的程序FC_RJS_INCLUIR_RELACAO_PRODCAT返回一个整数值。如果是这样,您的代码应该更像这样:

CallableStatement clstAddRel = conn.prepareCall(" { ? = call FC_RJS_INCLUIR_RELACAO_PRODCAT(?,?)} ");
clstAddRel.registerOutParameter(1, Types.INTEGER);
clstAddRel.setString(2, Integer.toString(id_produto_interno));
clstAddRel.setString(3, ac[i].toString());
clstAddRel.execute();