java调用oracle的函数,从Java调用Oracle函数

I am having issues calling an Oracle FUNCTION (not a Stored Procedure) from Java 1.6, using ojdbc14.jar.

I do not know what the function contains as I am calling it from a remote server, all I know is this:

FUNCTION ap_ch_get_acct_balances (VAR_PI_MOB_NO_ACCT_NO VARCHAR2,

VAR_REPLY_CODE OUT NUMBER, VAR_EXT_RESPONSE OUT VARCHAR2, VAR_PO_ACC_BAL OUT CHAR,

VAR_PO_ACCT_NO OUT CHAR)

The schema I need to use is: FCRLIVE.AP_CH_GET_ACCT_BALANCES

I am trying this:

String call = "{ ? = call FCRLIVE.AP_CH_GET_ACCT_BALANCES(?, ?, ?, ?, ?) }";

CallableStatement cstmt = conn.prepareCall(call);

cstmt.setQueryTimeout(1800);

cstmt.setString(1, inputCode);

cstmt.registerOutParameter(2, oracle.jdbc.OracleTypes.NUMBER);

cstmt.registerOutParameter(3, oracle.jdbc.OracleTypes.VARCHAR);

cstmt.registerOutParameter(4, oracle.jdbc.OracleTypes.CHAR);

cstmt.registerOutParameter(5, oracle.jdbc.OracleTypes.CHAR);

cstmt.executeUpdate();

But I keep seeing this in the log file:

java.sql.SQLException: ORA-01006: bind variable does not exist

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)

at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)

at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:573)

at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891)

at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1093)

at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2047)

at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1940)

at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2688)

at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)

Am I calling the function wrong? Or what could this possibly be?

Thanks in advance for the help!

解决方案

it should be:

String call = "{ ? = call FCRLIVE.AP_CH_GET_ACCT_BALANCES(?, ?, ?, ?, ?) }";

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值