Re: function retuning refcursor, order by ignored? - Mailing list pgsql-general

From novnov
Subject Re: function retuning refcursor, order by ignored?
Date
Msg-id 10879984.post@talk.nabble.com
Whole thread Raw
In response to Re: function retuning refcursor, order by ignored?  (Alvaro Herrera <alvherre@commandprompt.com>)
Responses Re: function retuning refcursor, order by ignored?
Re: function retuning refcursor, order by ignored?
List pgsql-general
While a hard coded order by clause works; passing the order by as a param is
ignored as I've implemented below.  The order by value is being passed as
expected (tested by outputing the value in a column). I've called like so:

ups=# begin;
BEGIN
ups=# select proc_item_list(1,true,'item_id');
   proc_item_list
---------------------
 <unnamed portal 12>
(1 row)

ups=# fetch all from "<unnamed portal 12>";


CREATE or REPLACE FUNCTION "public"."proc_item_list"(
IN "pint_org_id" int4,
IN "pbool_active" bool,
IN "pstr_orderby" varchar)
RETURNS "pg_catalog"."refcursor" AS
$BODY$
DECLARE
     ref refcursor;
BEGIN
     OPEN ref FOR SELECT item_id, item_name, item_org_id, item_active
          FROM public.t_item
          WHERE item_org_id = "pint_org_id" and item_active = "pbool_active"
          ORDER BY "pstr_orderby";
     RETURN ref;
END;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;

--
View this message in context:
http://www.nabble.com/function-retuning-refcursor%2C-order-by-ignored--tf3837519.html#a10879984
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


pgsql-general by date:

Previous
From: Jeff Davis
Date:
Subject: Re: Uhm, so, yeah, speaking of /.
Next
From: "Joshua D. Drake"
Date:
Subject: Re: Uhm, so, yeah, speaking of /.