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.


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to