2015-03-13 2 views
0

Я пытаюсь вызвать SQL-процедуру из своего приложения ADF.Отсутствует индекс в :: 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) {} 
      } 
     } 
} 

И это в моем бэк-боба, где я звоню предыдущий метод:

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

Что я делаю неправильно? Я попробовал изменить оператор callable и номер в cs.setString(). Однако проблема остается прежней.

EDIT: После внесения некоторых изменений в код, я тестировал 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); 

И убедитесь, что вы проверили свою процедуру у тестера BC, прежде чем отсылать ее от бэк-бэнда. Меньшие шаги всегда бывают быстрее.

+0

Не работает, в любом случае, но ошибка изменилась. Http://puu.sh/gyrft/db45c05976.png – SaintLike

+0

Вы тестируете тестер BC? –

+0

Я не был, но у меня там такая же ошибка, но более длинное описание – SaintLike