Changing the WHERE or ORDER BY Clause of a Query at Runtime

You can change the WHERE and ORDER BY clauses of a query at runtime by calling setWhereClause() or setOrderByClause() on the view object.

Note: setWhereClause() is the easiest way to change a view object's query, but often it is not the most efficient. If you can, you should use parametrized WHERE clauses or structured WHERE clauses. For more information, see the related topics list.

To change the WHERE clause of a query at runtime:

  1. Create a String containing the new WHERE clause. Do not include the word "WHERE". If you do want to remove the WHERE clause entirely, use null. For example, either of the following could be appropriate definitions:
    String whereClause = "ORDER_TOTAL > 500";
    String whereClause = null;                
  2. Pass this string into setWhereClause(). For example, if OrdVO is a variable containing the view object instance to be changed, you would call:

    ordVO.setWhereClause(whereClause);

To change the WHERE clause of a query at runtime:

  1. Create a String containing the new ORDER BY clause. Do not include the words "ORDER BY". If you do want to remove the ORDER BY clause entirely, use null. For example, either of the following could be appropriate definitions:
    String orderByClause = "ORDER_TOTAL";
    String whereClause = null;                
  2. Pass this string into setOrderByClause(). For example, if OrdVO is a variable containing the view object instance to be changed, you would call:

    ordVO.setOrderByClause(orderByClause);


Ways to Change View Object Queries at Runtime
About View Objects
About View Object and View Link Instances
Specifying a Custom Query for a View Object Definition
Finding View Object Instances in the Data Model
Using Parametrized WHERE Clauses
Using Structured Where Clauses


 

 

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