Re: function retuning refcursor, order by ignored?

Поиск
Список
Период
Сортировка
От novnov
Тема Re: function retuning refcursor, order by ignored?
Дата
Msg-id 10867454.post@talk.nabble.com
обсуждение исходный текст
Ответ на Re: function retuning refcursor, order by ignored?  (Michael Fuhr <mike@fuhr.org>)
Список pgsql-general
Hmm, well if both of you say that ORDER BY is not somehow ignored by
refcursor functions then I'm sure you're right. I'm just very clusmy in my
testing of the output...somehow the output order by is being lost. I've been
testing via the results in a web app and have had issues with executing the
proc in postgres directly. I think the example you've provided here may help
me.

Thanks to both of you.



Michael Fuhr wrote:
>
> 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
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
>        subscribe-nomail command to majordomo@postgresql.org so that your
>        message can get through to the mailing list cleanly
>
>

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


В списке pgsql-general по дате отправления:

Предыдущее
От: Rodrigo De León
Дата:
Сообщение: Re: SELECT from mytbl;
Следующее
От: Erwin Brandstetter
Дата:
Сообщение: Re: SELECT from mytbl;