Define and remove named bind variable in viewObject at runtime programmatically

Sharing is Caring

This post is about creating named bind variable in viewObject at runtime and filter viewObject using this bind variable in WHERE Clause of ViewObject programmatically. Sometimes we face this type of problem in ADF application and we need to perform this task.

Defining WHERE Clause and Bind Variable name and default value –

//Get ViewObject
ViewObject vo = iter.getDepartments();

//Apply desired WHERE Clause and declare bind variable name
vo.setWhereClause("DEPARTMENT_NAME=:BindDepartmentName");

//Define this variable as ViewObject Bind Variable , You can also set default value for this
vo.defineNamedWhereClauseParam("BindDepartmentName", "Purchase", null);

// Execute ViewObject to finally apply where clause
vo.executeQuery();

Setting value of Bind Variable-

        //Setting Value of Bind Variable
        vo.setNamedWhereClauseParam("BindDepartmentName", "Finance");
        vo.executeQuery();

Getting value of Bind Variable-

        //Get value of Bind Variable
        vo.getNamedWhereClauseParam("BindDepartmentName");

Removing WHERE Clause and Bind Variable after use-

        //Remove where clause
        vo.setWhereClause(null);
        //Remove Bind Variable
        vo.removeNamedWhereClauseParam("BindDepartmentName");
        vo.executeQuery();

Cheers 🙂 Happy Learning

Related Posts

0 thoughts on “Define and remove named bind variable in viewObject at runtime programmatically”

  1. Hi Ashish, but actually wanted to if we have to use comma separated values, in the sense if we have to use IN clause then how we should go through. The one which you have posted here is w.r.t to single value bind variable.

  2. Actually I have already tried the post which you have advised but there it's including subString as well. Suppose I have to see the results of Dept=164 then it's showing the result of Dept=164 and 64 as well. And one more problem I'm facing, I have got a PanelTab where two tabs are there. In both the tabs tables are displayed. Both the tables refers to same DB table, but only one difference is that views of both the tables are difference based on one column Status. In first tab results are displayed based on status='Y' and in next tab results are displayed based on status='N'. I can move the records from 2nd tab to first and vice-versa. But whenever I'm moving data from 2nd tab to 1st tab so ideally it should display in 1st tab. But when I'm trying to move to 1st tab to see the moved record the whole table becomes empty. Th ViewObject which has been used to show the results is giving 0 rowcount.

  3. Yes I'm moving the data by updating the status. I'm committing the data and then trying to execute the View Object. The ViewObject consists of Bind Variables and from View Layer Backing bean I'm execution vo.setNamedWhereClauseParam("bind_variable", data) vo.executeQuery() and vo.getRowCount() gives 0 rows.

Leave a Reply

Your email address will not be published. Required fields are marked *