Order by parameter inside pgsql function ignored - Mailing list pgsql-general

Hi!

I'm trying to use the order by parameter inside a function, but it is
ignored. Any ideas why? And how can I sort by external parameters inside
pgsql function?

CREATE OR REPLACE FUNCTION "public"."test_order_by" (sort_key varchar)
RETURNS SETOF "customers"."customers_with_mark_deleted" AS
$body$
DECLARE
   rec RECORD;
BEGIN
     FOR rec IN SELECT * FROM customers.customers_with_mark_deleted c
         ORDER BY sort_key ASC
       LOOP
           RETURN NEXT rec;
       END LOOP;
   RETURN;
END;
$body$
LANGUAGE 'plpgsql'
VOLATILE
CALLED ON NULL INPUT
SECURITY INVOKER
COST 100 ROWS 1000;

--
Best regards,
Anton Marchenkov.


pgsql-general by date:

Previous
From: Douglas Alan
Date:
Subject: Re: How can I manually alter the statistics for a column?
Next
From: "Leif B. Kristensen"
Date:
Subject: Re: Order by parameter inside pgsql function ignored