Define WHERE Clause on dynamic ViewObject created on the fly

Sharing is Caring

We all know there are different ways to define WHERE clause on a viewObject at runtime and previously I have posted about it. In this post, I’ll show you how to define WHERE Clause on dynamic viewObject created at runtime using SQL query
Check –

ADF Basics: Apply and Change WHERE Clause of ViewObject at runtime programmatically
ADF Basics: Define and remove named bind variable in viewObject at runtime programmatically
Setting view object bind variable (Override bindParametersForCollection, prepareRowSetForQuery, executeQueryForCollection )

So for this created a dummy view object using dual



WHERE Clause on dynamic ViewObject

Now remove this dummy viewObject and create new ViewObject with the same name using query

        //Get dummy viewObject
        ViewObject dynVo = this.getdynamic1();
        //Remove viewObject from Application Module
        //Creates a read-only View Object, given a query statement and a name for the View Object.
        this.createViewObjectFromQueryStmt("dynamic1", "SELECT * FROM DEPARTMENTS");

There is no difference in the syntax of the setWhereClause method but here we pass JDBC Positional bind variable using “?” symbol

//Apply desired WHERE Clause and declare bind variable 

//Pass Bind Variable value using index
dynVo.setWhereClauseParam(0, "Finance");

// Execute ViewObject to finally apply where clause

This is how we can apply WHERE clause on dynamic view objects
Cheers 🙂 Happy Learning

Related Posts

Leave a Reply

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