Sorting data from a query

You define a sort in a query to extract data in a specific order.

Before you begin

Add a query to an element.

About this task

A sort can be specified using the native sort or IBM® Rational® Publishing Engine sort. The native sort allows you to enter the sort in the format supported native to the data source. A native sort is interpreted by the data source, while a Rational Publishing Engine sort is processed by Rational Publishing Engine as it extracts data from the data source.

For more information on native sorts, consult the Integrating section of this information center for your data source and the information center for that data source to find details on the appropriate syntax.

Procedure

  1. Select an element in the template content editor.
  2. In the Properties view, expand Data.
  3. In the Sort property, click the ellipsis. The Sort Editor window displays.
  4. Specify the sort conditions:
    • To use the Rational Publishing Engine sort, click the Script tab to add to the sort expression.
      1. Select an attribute from the available attributes column.
      2. Click the >> icon to add the attribute to the selected column.
      3. For the Direction, select Ascending or Descending.
      4. For Sort as, select one of the following values:
        • Number: Sorts the data as numeric values. You can use this value when an attribute is defined as a string in the schema, but the values are all numbers.
        • Text: Sorts the data as string values.
        • No selection: You can leave the value deselected. The default value is no selection so that the data is sorted by the information defined in the schema.
        Note: If you are unsure whether the data contains number or text values, leave the Sort as value deselected.
        • If you select the wrong sort type, the sort might produced undefined results.
        • If all of the values have an identical string prefix followed by a number and you select Number for the Sort as field, the data might sort correctly in some circumstances and not in others.
        In both of these situations, leave the Sort as value deselected.
      5. Click OK.
    • To use a native sort, click the Native tab and enter the sort expression in the Native window. Click OK.

    Whenever possible, use a native sort. The native sort generates documents more quickly than a Rational Publishing Engine sort.

  5. Click OK.

Results

The selected sort order is added to the current element.
Note: Rational Publishing Engine cannot check if the native sort is correct. Compare the sort with a sort in the data source to verify accuracy.

What to do next

You can remove the sort expressions by clicking Remove option displayed against each item. To remove all items, click Remove All.

Feedback