sortExpression

Type: String

The sortExpression property of the ExternalCollection class contains the string expression used to override the default sort or SQL ORDER BY specification defined for an external collection. The sort expression should not contain the ORDER BY SQL keywords. The filtering expression (filterExpression) must be defined in terms of external column names and not the attribute names to which they are mapped. If the resultant SQL statement is not valid, an ODBC exception is raised.

The following example shows the use of the sortExpression and filterExpression properties to create a shared external collection instance, set the filter and sort expressions, and then use a foreach instruction to fetch the instances. (Alternatively, you could use an iterator to fetch the instances.)

findRichCustomers();
    accounts : CustomerAccountDict;
    account  : Account;
begin
    create accounts;
    accounts.filterExpression := "account.balance > 100000";
    accounts.sortExpression   := "account.balance";
    foreach account in accounts do
        display(account.number, account.name);
    endforeach;
epilog
    delete accounts;
end;