首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >缺失索引:2

缺失索引:2
EN

Stack Overflow用户
提问于 2015-03-13 12:19:55
回答 1查看 119关注 0票数 0

我试图从我的ADF应用程序中调用一个SQL过程。

我的AppModule中有以下代码:

代码语言:javascript
复制
public void callProcedureSimulateFromDB(String idCategoria) {
    CallableStatement cs = null;
    System.out.println("categoria-> " + idCategoria);
try {
    cs = getDBTransaction().createCallableStatement("begin ? := SPSIMULATE(?); end;", 0);

    cs.setString(2, idCategoria);
    cs.execute();

} catch (SQLException e) {
    throw new JboException(e);

} finally {
            if (cs != null) {
                try {
                    cs.close();
                }catch (SQLException e) {}
            }
        }
}

在我的后台bean中,我调用了前面的方法:

代码语言:javascript
复制
public String simulate() {
    String categoria = catIdId.getValue().toString();
    if (categoria != null && !categoria.isEmpty()) {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        Application app = facesContext.getApplication();
        ExpressionFactory elFactory = app.getExpressionFactory();
        ELContext elContext = facesContext.getELContext();
        ValueExpression valueExp = elFactory.createValueExpression(elContext, "#{bindings}", Object.class);
        oracle.binding.BindingContainer binding = (oracle.binding.BindingContainer)valueExp.getValue(elContext);
        OperationBinding operationBinding = binding.getOperationBinding("callProcedureSimulateFromDB");

        // Set the Input parameters to the operation bindings as below
        operationBinding.getParamsMap().put("idCategoria", categoria);

        // Invoke the Application module method
        operationBinding.execute();
        // Get the result from operation bindings
        //Object obj = operationBinding.getResult();
        //System.out.println("obj ----> " + obj);
    }
    //ADFContext.object.applicationModule.myAMMethod() ;
    //chamar funçao da DB
    p55.hide();
    return null;
}

我得到了以下错误:

我做错了什么?我尝试过更改de callable语句和cs.setString()中的数字。然而,问题依然存在。

编辑:对代码做了一些更改之后,我测试了AppModule并得到了以下错误:

代码语言:javascript
复制
(oracle.jbo.JboException) JBO-29000: Unexpected exception caught: java.sql.SQLException, msg=ORA-06550: line 1, column 7:
PLS-00103: Encountered the symbol "=" when expecting one of the following:

   ( begin case declare exit for goto if loop mod null pragma
   raise return select update while with <an identifier>
   <a double-quoted delimited-identifier> <a bind variable> <<
   continue close current delete fetch lock insert open rollback
   savepoint set sql execute commit forall merge pipe purge
The symbol "<an identifier>" was substituted for "=" to continue.
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-03-13 12:42:42

如果SPSIMULATE是一个存储过程(而不是存储函数),您可以尝试更改这一行:

代码语言:javascript
复制
 cs = getDBTransaction().createCallableStatement("begin ? := SPSIMULATE(?); end;", 0);

代码语言:javascript
复制
  cs = getDBTransaction().createCallableStatement("{call SPSIMULATE(?)}", 0);

并确保您在从bean测试过程之前,从后台bean对其进行标注。较小的步伐总是更快。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29032110

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档