2015-03-13 98 views
0

我想从我的ADF应用程序调用SQL过程。缺少索引:: 2

我在我的AppModule下面的代码:

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中,在那里我打电话前面的方法:

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; 
} 

我得到以下错误:

enter image description here

我在做什么错?我已经尝试更改de callable语句和cs.setString()中的数字。但是,问题保持不变。

编辑: 做一些改变的代码后,我测试中的AppModule并得到了以下错误:

(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. 

回答

0

如果SPSIMULATE是一个存储过程(而不是存储功能),你可以试试改变这一行:

cs = getDBTransaction().createCallableStatement("begin ? := SPSIMULATE(?); end;", 0); 

cs = getDBTransaction().createCallableStatement("{call SPSIMULATE(?)}", 0); 

在确定你从后台bean进行调用之前,确保你从BC Tester测试了你的过程。更小的步骤总是更快。

+0

无论如何不工作,但错误更改http://puu.sh/gyrft/db45c05976.png – SaintLike 2015-03-13 12:54:34

+0

您是从BC测试者测试吗? – 2015-03-13 12:58:33

+0

我不是,但我得到了同样的错误,但更长的描述 – SaintLike 2015-03-13 13:57:50