Lists: | pgsql-general |
---|
From: | Mike Christensen <mike(at)kitchenpc(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Can a function return more then one table? |
Date: | 2012-01-11 06:42:22 |
Message-ID: | CABs1bs3d2vRmv9WtFfNnxu2j30Tc4F-P-f3Yooyif0imSLfMqg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
I would like to write a function that returns one row from one table,
and about 10 rows or so from another table..
Is there a clean way to do this, or am I better off making two separate queries?
I'm thinking maybe I can use OUT parameters for the first table, and
the return value for the second table? However, I have no idea what
the syntax would be like.
Mike
From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | Mike Christensen <mike(at)kitchenpc(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Can a function return more then one table? |
Date: | 2012-01-11 06:47:38 |
Message-ID: | CAFj8pRDHgkmSrhw9oMe+H9MWr1ELF+8kok=a4t-QQNO9d_wmzA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
Hello
2012/1/11 Mike Christensen <mike(at)kitchenpc(dot)com>:
> I would like to write a function that returns one row from one table,
> and about 10 rows or so from another table..
>
> Is there a clean way to do this, or am I better off making two separate queries?
>
> I'm thinking maybe I can use OUT parameters for the first table, and
> the return value for the second table? However, I have no idea what
> the syntax would be like.
>
what is possible
* return setof refcursors
* use arrays instead tables and returns arrays (for tables less 10000 rows)
Regards
Pavel Stehule
> Mike
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
From: | Mike Christensen <mike(at)kitchenpc(dot)com> |
---|---|
To: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Can a function return more then one table? |
Date: | 2012-01-11 06:50:31 |
Message-ID: | CABs1bs1wTRp1vPgJGyuCOwaU-SpSbB+qPLw-YTBA6EtZd1GHrA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
> 2012/1/11 Mike Christensen <mike(at)kitchenpc(dot)com>:
>> I would like to write a function that returns one row from one table,
>> and about 10 rows or so from another table..
>>
>> Is there a clean way to do this, or am I better off making two separate queries?
>>
>> I'm thinking maybe I can use OUT parameters for the first table, and
>> the return value for the second table? However, I have no idea what
>> the syntax would be like.
>>
>
> what is possible
>
> * return setof refcursors
> * use arrays instead tables and returns arrays (for tables less 10000 rows)
Thanks! Both of these options sound feasible, I will play around with
some code and see what I can come up with.
Mike
From: | Sergey Konoplev <gray(dot)ru(at)gmail(dot)com> |
---|---|
To: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
Cc: | Mike Christensen <mike(at)kitchenpc(dot)com>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: Can a function return more then one table? |
Date: | 2012-01-11 11:50:25 |
Message-ID: | CAL_0b1t1yv4LihAZajL7ebDibLcfN4+mc3pTDp+7DT5=F1SmKQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
On Wed, Jan 11, 2012 at 10:47 AM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote:
> * return setof refcursors
> * use arrays instead tables and returns arrays (for tables less 10000 rows)
One more option is to use hstore plus populate_record().
>
> Regards
>
> Pavel Stehule
>
>> Mike
>>
>> --
>> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-general
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
--
Sergey Konoplev
Blog: http://gray-hemp.blogspot.com
LinkedIn: http://ru.linkedin.com/in/grayhemp
JID/GTalk: gray(dot)ru(at)gmail(dot)com Skype: gray-hemp