Reputation: 1265
I want to go through the records in descending order by Field4
, but when I put in the code BY mybuffer.Field4 DESCENDING
I get the error
After "Field4 DESCENDING" not understandable (247) [translated].
FOR EACH mybuffer
WHERE mybuffer.Field1 = value1
AND mybuffer.Field2 = value2
AND mybuffer.Field3 >= value3
BY mybuffer.Field4 DESCENDING
USE-INDEX myindex
NO-LOCK:
/* do something */
END.
What I am doing wrong?
Upvotes: 1
Views: 1521
Reputation: 14020
The error is the placement of USE-INDEX "After field 4 descending". Just like the error message says.
The correct syntax is:
for each customer no-lock use-index cust-num
where sales-rep = "BBB"
by city:
display customer.
end.
FWIW it is unlikely to be a good idea to have both USE-INDEX in a FOR EACH loop and even less likely to be a good idea to be combining it with BY. The compiler will probably choose a better index (or indexes plural) if you allow it to.
Upvotes: 1
Reputation: 7192
Although I'm not sure that the combination of USE-INDEX and BY is smart. But your problem is likely to be the order of options.
Use in this order:
Upvotes: 1