I wrote a function to return a set of records (RETURNS SETOF) , using return next.
Is there a way to sort the result set before returning? something like accessing a reference of the set, sort it, then return.
I already did use order by in some queries, but i need to write additional code to sort the result.
As a workaround i’m calling the function like this:
select * from (select * from myfunction() ) d
order by d.whatever,d.othercolumn
Thanks.
If you are unable to order data before return next – you can wrap call of your function in another function, select data from it with desired ordering and return it.