Skip site navigation (1) Skip section navigation (2)

Re: function retuning refcursor, order by ignored?

From: novnov <novnovice(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: function retuning refcursor, order by ignored?
Date: 2007-05-30 18:40:15
Message-ID: 10879984.post@talk.nabble.com (view raw or flat)
Thread:
Lists: 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.


In response to

Responses

pgsql-general by date

Next:From: Joshua D. DrakeDate: 2007-05-30 18:41:00
Subject: Re: Uhm, so, yeah, speaking of /.
Previous:From: Jeff DavisDate: 2007-05-30 18:31:47
Subject: Re: Uhm, so, yeah, speaking of /.

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group