Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
5
Erster Beitrag:
vor 3 Jahren
Letzter Beitrag:
vor 3 Jahren
Beteiligte Autoren:
Noel Tanti, DerekT, J. Flietstra, Arie

WD19 - Query Sort

Startbeitrag von Noel Tanti am 15.02.2015 11: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

Antworten:

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..

von J. Flietstra - am 15.02.2015 12:05
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.

von Arie - am 15.02.2015 12:09
Thanks. will try the sort on parameter

von Noel Tanti - am 15.02.2015 13:17
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 -

von DerekT - am 16.02.2015 18:46
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.