Order by parameter inside pgsql function ignored

From: Anton Marchenkov <mad(at)handybank(dot)ru>
To: pgsql-general(at)postgresql(dot)org
Subject: Order by parameter inside pgsql function ignored
Date: 2009-06-02 07:38:56
Message-ID: 4A24D710.30803@handybank.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Leif B. Kristensen 2009-06-02 08:20:21 Re: Order by parameter inside pgsql function ignored
Previous Message Douglas Alan 2009-06-02 07:09:55 Re: How can I manually alter the statistics for a column?