BINARY SEARCH or DELETE ADJACENT DUPLICATES without a matching SORT

 home  single file   example  edit

sort_required

Description

BINARY SEARCH or DELETE ADJACENT DUPLICATES ... COMPARING on a local table not sorted by those fields

Extended Information

READ TABLE ... WITH KEY ... BINARY SEARCH only finds the row when the table is sorted ascending by
the key fields, in the order of the key. DELETE ADJACENT DUPLICATES ... COMPARING only removes all duplicates
when rows with equal values in the compared fields are next to each other. Neither statement checks the order:
on an unsorted table they give wrong results, without a dump.

Checked: a standard table declared with DATA in the method, form or function module, read with WITH KEY
and BINARY SEARCH, or with DELETE ADJACENT DUPLICATES ... COMPARING. Reported when
- the last SORT of the table before the statement is not by the key fields: for BINARY SEARCH they must be
the first sort fields, in the same order and ascending; for COMPARING the first sort fields must be the
compared fields, in any order. A SORT without BY uses the primary key.
- there is no SORT of the table before the statement, and it is filled by a SELECT without ORDER BY: the
database returns the rows in no defined order.

Not reported: parameters, attributes, global and static variables, a table that can get its rows sorted
from elsewhere (an assignment, a method or function call, APPEND or INSERT LINES OF, SELECT ... ORDER BY)
after the SORT or, without a SORT, anywhere in the procedure, a table without SORT filled only by APPEND,
INSERT or COLLECT (the code can add the rows in order), sorted and hashed tables, SORT with STABLE or with
dynamic fields, a SORT later in a loop around the statement, a SORT without BY on a default key of a
structured row, WITH TABLE KEY, USING KEY, dynamic components and COMPARING ALL FIELDS.
See also sort_empty_key and sequential_read_sorted.

Default Configuration

Hover to see descriptions, Ctrl+Space for suggestions

Examples