User Tools

Site Tools

Navigation:  Language Reference > 5 - Declaration Attributes > Variable and Entity Attributes >====== ORDER (set view sort order expression) ====== Previous pageReturn to chapter overviewNext page

ORDER(expression list)


ORDER Specifies an expression list used to sort the records in the VIEW.
expression list A single string constant containing one or more expressions. Each expression in the list must be separated by a comma from the preceding expression.

The ORDER attribute (PROP:ORDER) specifies an expression list used to sort the records in the VIEW. The expressions within the expression list evaluate from left to right, with the leftmost expression defining the most significant sort and the rightmost defining the least significant sort. Expressions that begin with a unary minus (-) sort in descending order.

The expression may reference any field in the VIEW, at all levels of JOIN structures. The expressions in the expression list may contain any valid Clarion language expression. The expression list is evaluated at runtime (just like the EVALUATE procedure), therefore you must BIND all variables used in the expression.

For non-SQL file systems, the VIEW will use keys to do most of the sorting wherever possible, sorting only groups of records which have the same key values, keeping one 'bucket' sorted. Therefore, additional sort fields on top of a key can be quite efficient.

For SQL file systems, PROP:SQLOrder is an SQL-only equivalent to PROP:ORDER. For both of these properties, if the first character of the expression assigned to them is a plus sign (+) then that expression is concatenated to the existing order expression. For PROP:SQLOrder, if the first character of the expression assigned is a minus sign (-) then the existing order expression is concatenated to that expression. If the first character is not plus (or minus), the new expression overrides the existing expression.


!Orders sorted in descending date order, then customer name (by name within each date)
ViewOrder VIEW(Customer),ORDER('-Hea:OrderDate,Cus:Name')
          JOIN(Hea:AcctKey,Cus:AcctNumber)           !Join Header file
           JOIN(Dtl:OrderKey,Hea:OrderNumber)        !Join Detail file
            JOIN(Pro:ItemKey,Dtl:Item)               !Join Product file
    ViewOrder{PROP:ORDER} = '-Hea:OrderDate,Pro:Price-Det:DiscountPrice'
       !Orders sorted by greatest discount within descending order date
       !ABC Implementation example of PROP:SQLORDER
       !For browse, after files and window are opened
    BRW1::View:Browse{PROP:SQLOrder} = ‘Phone’  
      !where Phone is a column name in SQL database
      !For reports, after files and progress window are opened:
    Process:View{PROP:SQLOrder} = ‘au_lname’
      !where au_lname is a column name in SQL database

See Also:





order_set_view_sort_order_expression_.htm.txt · Last modified: 2023/09/08 07:39 by carlbarnes