Saturday, May 11, 2013

ADF 11G : How to pass the bind variable programatically?

ADF 11G : How to pass the bind variable programatically?

Below  example shows blind search along with bind variable.






 


**************************************************

public String executeWithCustomWhereClause(){
       
        ViewObject empVO = getEmployeesView1();
        empVO.setWhereClause("Employees.FIRST_NAME= :fName");
        empVO.defineNamedWhereClauseParam("fName", null, null);
        empVO.setNamedWhereClauseParam("fname", "nj");
       
        System.out.println(empVO.getQuery());
            empVO.executeQuery();
        return null;
        }




    public String executeWithEmpId(Integer empId){
      
        ViewObject empVO = getEmployeesView1();
        VariableValueManager empVM=  empVO.ensureVariableManager();
        empVM.setVariableValue("empId", empId);
        System.out.println(empVO.getQuery());
        empVO.executeQuery();

        return null;
        }


public Row findEmployeeForEmpId(Integer empId){

String whereClause = "EmployeeEO.EMPLOYEE_ID = :1";

ViewObject empVO =getEmployeesView1();
empVO.setWhereClause(whereClause);
empVO.setWhereClauseParam(1,empId);
empVO.executeQuery();
return null;
}