Hi Alex,

thank you. just what i need.

/e

On Tue, May 24, 2011 at 2:09 AM, Alexander Burger <a...@software-lab.de> wrote:
> Hi Edwin,
>
>> i'm trying to look for an example of sorting the output of database
>> queries by a given attribute.
>> ...
>> (class +MyClass +Entity)
>> (rel date (+Date))
>> ...
>> and if i run a query, i'd like to sort the output, say, by increasing date.
>
> There are two possibilities:
>
> 1. If this sorting is often necessary, you maintain an index for that
>   attribute:
>
>      (rel date (+Ref +Date))
>
>   Then all queries on that attribute will directly return sorted
>   results:
>
>      (collect 'date '+MyClass)
>      (collect 'date '+MyClass <fromDate> <tillDate>)
>
>      (pilog '((db date +MyClass @M) ...) ...)
>
>   Note, however, if 'select' is used with multiple search attributes,
>   the resulting order is not defined.
>
>
> 2. If you need to do that only once or seldom, sort the results after
>   fetching them:
>
>   (by '((This) (: date)) sort
>      (collect 'someOtherAttribute '+MyClass) )
>
>   This has the disadvantage that first all results must be fetched, of
>   course, before they can be sorted.
>
> Cheers,
> - Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to