Re: calling a function that takes a row type and returns a set of rows

From: "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com>
To: "Dimitri Fontaine" <dfontaine(at)hi-media(dot)com>
Cc: "Robert Haas" <robertmhaas(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: calling a function that takes a row type and returns a set of rows
Date: 2008-10-11 06:18:15
Message-ID: 162867790810102318o4129d1ay6960bc2b9607f490@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

2008/10/10 Dimitri Fontaine <dfontaine(at)hi-media(dot)com>:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi,
>
> Le 10 oct. 08 à 21:22, Robert Haas a écrit :
>>
>> I can't find any legal way of calling this function.
>>
>> SELECT bar(f) FROM foo f;
>> ERROR: set-valued function called in context that cannot accept a set
>>
>> SELECT * FROM foo f, bar(f);
>> ERROR: function expression in FROM may not refer to other relations
>> of same query level
>>
>> Any help appreciated.
>
>
> You need LATERAL support for this:
> SELECT * FROM foo f LATERAL bar(f);
>
> I'm not sure about the syntax, but LATERAL is a standard JOIN type wherein
> upper "nodes" are visible.
> - --
> dim
>

no, this strange syntax is far to any standard. Solution is using
dynamic cursor ala DB2 (that isn't supported in postgres) - select *
from fce(cursor(select .... from tab))

Regards
Pavel Stehule

> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (Darwin)
>
> iEYEARECAAYFAkjvvYMACgkQlBXRlnbh1blatgCgnaDoSY2RGzv224QWqA8OYEjx
> fbMAoK31dHoFjOVRdomvhl/qilndRZJ5
> =3xjL
> -----END PGP SIGNATURE-----
>
> --
> 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
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Martin Pitt 2008-10-11 10:37:30 Re: [Pkg-postgresql-public] Re: Postgres major version support policy on Debian
Previous Message IJS/System - Joko 2008-10-11 01:27:45 Re: logging SQL statements