Using Structured Where Clauses

View criteria are structured criteria that you can use to assemble a WHERE clause. Instead of changing WHERE clauses using string manipulation, you may find it more efficient to use view criteria to assemble complex WHERE clauses in conjunctive normal form. For more information, see About View Criteria.

To use structured WHERE clauses:

  1. Instantiate the a ViewCriteria class by calling createViewCriteria() on the view object instance. For example, to create view criteria for the view object instance custOrdVO , you could use the following code:
    ViewCriteria vc = custOrdVO.createViewCriteria();                
  2. For each view criteria row you will need, create a view criteria row by calling createViewCriteriaRow() on the ViewCriteria, for example:
    ViewCriteriaRow promotionRow = vc.createViewCriteriaRow();
    ViewCriteriaRow noPromRow = vc.createViewCriteriaRow();                
  3. Set the requirements for each view criteria row by calling setAttribute() on the ViewCriteriaRow. Pass setAttribute() the name of the view object attribute and the SQL requirement to be applied to the attribute:
    promotionRow.setAttribute("OrderTotal", "> 500");
    promotionRow.setAttribute("CreditLimit", "> 2500");
    promotionRow.setAttribute("PromotionId", "IS NOT NULL");
    
    
    noPromRow.setAttribute("OrderTotal", "> 1000");
    noPromRow.setAttribute("OrderTotal", "> 5000");                
  4. Add the rows to the view criteria by passing them to addElement() on the ViewCriteria:
    vc.addElement(promotionRow);
    vc.addElement(noPromRow);                
  5. Apply the view criteria to the view object instance by passing the ViewCriteria to applyViewCriteria():

    custOrdVO.applyViewCriteria(vc);

  6. At any time, you can do any of the following:

Ways to Change View Object Queries at Runtime
Ways to Change View Object Queries at Runtime
About Oracle ADF View Objects
About View Object Attributes

 

 

 

Copyright © 1997, 2004, Oracle. All rights reserved.