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

From Michael Fuhr
Subject Re: function retuning refcursor, order by ignored?
Date
Msg-id 20070530022912.GA73504@winnie.fuhr.org
Whole thread Raw
In response to function retuning refcursor, order by ignored?  (novnov <novnovice@gmail.com>)
Responses Re: function retuning refcursor, order by ignored?
Re: function retuning refcursor, order by ignored?
List pgsql-general
On Tue, May 29, 2007 at 05:18:42PM -0700, novnov wrote:
> It seems that at least in the way I've written the function below, ORDER BY
> is ignored.

Works here (see below).  Can you post a complete example that shows
ORDER BY being ignored?  Do you get different results from the
cursor than if you execute the same query directly?  What version
of PostgreSQL are you running?


CREATE TABLE t_item (
    item_id      integer PRIMARY KEY,
    item_name    text NOT NULL,
    item_org_id  integer NOT NULL,
    item_active  boolean NOT NULL
);

INSERT INTO t_item VALUES (4, 'four', 1, true);
INSERT INTO t_item VALUES (2, 'two', 1, true);
INSERT INTO t_item VALUES (1, 'one', 1, true);
INSERT INTO t_item VALUES (3, 'three', 1, true);

BEGIN;

SELECT proc_item_list(1, true);
   proc_item_list
--------------------
 <unnamed portal 1>
(1 row)

FETCH ALL FROM "<unnamed portal 1>";
 item_id | item_name | item_org_id | item_active
---------+-----------+-------------+-------------
       1 | one       |           1 | t
       2 | two       |           1 | t
       3 | three     |           1 | t
       4 | four      |           1 | t
(4 rows)

COMMIT;

--
Michael Fuhr

pgsql-general by date:

Previous
From: Naz Gassiep
Date:
Subject: Re: TimeZone List
Next
From: Francisco Reyes
Date:
Subject: Re: Delete with subquery deleting all records