Home page  
Help >
ddlReduce() - remove duplicate records from a collection
Version 7.11
ddlReduce() - remove duplicate records from a collection ddlReduce() - remove duplicate records from a collection

Prototype:
   void ddlReduce(
      CONTROL *ctl,
      char *OptnStr,
      char *ArgList);

Permitted values in OptnStr:
   /S - use the sorted collection as input

Form of ArgList:
      <cx> [<dgname>] <field-name1> [<field-name2>] ...

Description:
Remove duplicate records from the source collection based on the concatenated value, called the reduce-key:
       <field-name1> [<field-name2>] ...

For each unique reduce-key, the first occurring instance in the source collection is preserved; all subsequent instances are removed from the collection.

When the /S option is used, for each unique reduce-key, the first occurring instance in the sorted collection is preserved; all subsequent instances are removed from the collection. After the reduce function is completed, the sorted collection is closed, and the reduced native collection remains.

Notes:
1) ddlSort() with the /R option is functionally equivalent to ddlReduce(). In this case, the combined sort-key is also the reduce-key.

Duplicate records are removed from both the sorted collection and the raw collection. Records that occur first in the sorted order are the surviving records. Duplicate records that occur later in the sorted order are removed.

After the sort function is completed, the sorted collection remains. To access the reduced raw collection, use ddlClear() with the /S option.

Values returned in Control Structure:
Control.Ans1 Total number of records remaining in the source collection.
Control.Ans2 Total number of records in the source collection.

Copyright © 2019 , WhamTech, Inc.  All rights reserved. This document is provided for information purposes only and the contents hereof are subject to change without notice. Names may be trademarks of their respective owners.