Sorting table

Can i sort records on the table based on the input given by the user at run time ?

for example if i want to sort records in ascending order and to process it, if the user give ascending otherwise i have to use descending order and process it..

is it possible , without writing

if userinput = "asc" then
do:
sort in asc order
process the values
end
else
do:
sort in desc order
process the values
end.
 

Casper

ProgressTalk.com Moderator
Staff member
Or just write out the 2 queries (asc/desc) and depending on the sort you use either one of them.
 

tamhas

ProgressTalk.com Sponsor
One technique you might consider for very flexible reporting is to define a temp-table to store the data for the report ... something that is often useful for other reasons such as accumulating totals or merging together data from multiple sources ... and to provide a sort field on that table which is indexed. Then, fill the sort field with whatever data is appropriate to the user's requests. With two indexes defined on that field, one ascending and one descending, you can do just about anything. E.g., if the user asks for ascending by name, fill with name, but if they ask for descending by dollar amount, then format the amount in a standardized way as a string so that it will sort correctly and use the descending index.
 

lord_icon

Member
Use a variable.

CASE var:

WHEN wotEver THEN
DO:
FOR EACH table WHERE wotEver
PROCESSING HERE

FOR EACH table WHERE wotEver2
PROCESSING HERE
END.

ENDCASE.
 
Top