[TOC] [Prev] [Next] [Bottom]



<@DISTINCT>

Syntax

<@DISTINCT ARRAY=arrayVarName
[COLS=
compCol [compType] [, ...]] [SCOPE=scope]>

Description

Returns an array containing the distinct, or unique, rows in the input array.

The ARRAY attribute specifies the name of a variable containing an array. The COLS attribute specifies the column(s) to consider when checking for duplicate rows. Columns can be specified using either column numbers or names, with an optional comparison type specifier (compType).

Valid comparison types are SMART (the default), DICT, ALPHA, and NUM. DICT compares values alphabetically without considering case. ALPHA is a case-sensitive comparison. NUM compares values numerically. SMART checks whether values are numeric or alphabetic and performs a NUM or DICT comparison.

If the COLS attribute is omitted, all columns are considered using the SMART comparison type when eliminating duplicates.

Multiple columns may be specified, separated by commas. Each column specification may include a comparison type specifier. If the comparison type specification is used, it must follow the name or number of the column to be sorted, separated by a space. For example, COLS="1 NUM, 2 DICT" specifies that the first column's values are compared numerically, and the second column's values are compared alphabetically, not case-sensitive.

The SCOPE attribute specifies the scope of the variable specified as the value of the ARRAY attribute. If the scope is not specified, the default scoping rules are used.

Meta tags are permitted in any of the attributes.

Examples

If the local variable test contains the following array:


1 a
1 a
2 a
3 b
3 b
4 c
4 c
6 d
7 e
7.0 f

<@DISTINCT ARRAY="test" SCOPE="local"> returns:


1 a
2 a
3 b
4 c
6 d
7 e
7.0 f

<@DISTINCT ARRAY="test" COLS="1 NUM" SCOPE="local"> returns:


1 a
2 a
3 b
4 c
6 d
7 e

<@DISTINCT ARRAY="test" COLS="2" SCOPE="local"> returns


1 a
3 b
4 c
6 d
7 e
7.0 f

:

See Also

<@FILTER>
<@INTERSECT>
<@SORT>
<@UNION>



[TOC] [Prev] [Next] [Bottom]



docs@pervasive.com

Copyright © 1998, Pervasive Software Inc. All rights reserved.