First page Back Continue Last page Graphics


Changing View Object WHERE or ORDER BY Clause at Run Time (continued)

To change the ORDER BY clause of a query at run time, perform the following steps:

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 orderByClause = 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);