Consultor Eletrônico



Kbase P173895: ** COUNT-OF requires a preselect sort. Try COUNT instead. (1142)
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   08/10/2010
Status: Unverified

SYMPTOM(s):

** COUNT-OF requires a preselect sort. Try COUNT instead. (1142)

Running code that uses a BREAK BY an active index generates the error:
/* Breaking by any active index generates the error */
FOR EACH customer NO-LOCK BREAK BY NAME :
IF FIRST-OF(Name) THEN DO:
MESSAGE COUNT-OF(Name)
VIEW-AS ALERT-BOX INFO BUTTONS OK.
LEAVE.
END.
END.

FACT(s) (Environment):

All Supported Operating Systems
Progress 8.x
Progress 9.x
OpenEdge 10.x

CAUSE:

This is expected behavior. The COUNT-OF needs a sorted preselected list of records to function. This sorted preselected list is not constructed if the BREAK is by an active index because the compiler optimization knows the list is already sorted.

FIX:

Do not break by an indexed field. If you must break by an indexed field, then force the compiler to use another index to preselect and sort the result set. For example:
/* Breaking by any active index generates the error */
FOR EACH customer NO-LOCK USE-INDEX CustNum BREAK BY NAME :
IF FIRST-OF(Name) THEN DO:
MESSAGE COUNT-OF(Name)
VIEW-AS ALERT-BOX INFO BUTTONS OK.
LEAVE.
END.
END.