2015-03-13 150 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