PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → WD19 - Query Sort
WD19 - Query Sort
Iniciado por guest, 15,feb. 2015 12:46 - 4 respuestas
Publicado el 15,febrero 2015 - 12:46
Hi

I need to select which field to sort by, by passing a parameter. Is this possible?
If a query has two fields ( code and description), sometimes I need to sort by code some times by descrtiption.
Do I need to create two queries?
I cannot use an array as this query is going into an array of structures and arraysort does not work.


Thank
Noel
Publicado el 15,febrero 2015 - 13:05
hi Noel

Yes you can edit the query and set the sort as a parameter

SELECT *
FROM Table
WHERE
table.field1 = {pField1}
SORT BY
{pSort}

Now you can assign the pSort as query parameter and when you assign a NULL the sort is omitted..
Publicado el 15,febrero 2015 - 13:09
Noel,
you can provide the "sort" you need as a parameter. Just like where-parameters.
If you open the queyr in the designer, just click on the action-part on the right side.
There's a SORT option where you will find the "sort on a parameter'

btw: sorting an array of structures is perfectly possible. You just need the proper syntax, which can be a bit of pain indeed.
Publicado el 15,febrero 2015 - 14:17
Thanks. will try the sort on parameter
Publicado el 16,febrero 2015 - 19:46
Quote
Arie Mars

Noel,

you can provide the "sort" you need as a parameter. Just like where-parameters.

If you open the queyr in the designer, just click on the action-part on the right side.

There's a SORT option where you will find the "sort on a parameter'



btw: sorting an array of structures is perfectly possible. You just need the proper syntax, which can be a bit of pain indeed.

Arie
Not that much of a pain;)....
ArraySort(MyArray,asMember,"MemberName") Same sort options apply: more than one member - separate by ";", mixed direction - prefix with + or -