From: Tom Lane <tgl@sss.pgh.pa.us>
To: Joel Burton <jburton@scw.org>
Cc: pgsql-sql@postgresql.org
Subject: Re: Can I create a function that returns many records?
Date: Wed, 19 Jul 2000 14:21:58 -0400
Message-ID: <22054.964030918@sss.pgh.pa.us> (raw)
In-Reply-To: <3975A98C.26157.984840B@localhost>
References: <3975A98C.26157.984840B@localhost>
"Joel Burton" <jburton@scw.org> writes:
> Working through the documentation, I see examples using CREATE
> FUNCTION METAPHONE(text) RETURNS setof tblPerson AS 'SELECT
> * FROM tblPerson' LANGUAGE 'sql', but this returns only a single
> numeric value (that doesn't seem to correspond to anything.)
IIRC, you can build a function that returns a SETOF any simple datatype,
but the support for returning tuples is suffering from bit-rot.
(I imagine it worked, more or less, back in Berkeley days.) If you can
live with returning one column at a time, you might be OK.
SELECT function-returning-set is a pretty peculiar notation anyway,
since SQL doesn't really have any concept of set data types in
expressions. What's more likely to be supported someday is a
function-returning-set used as a source table in a SELECT's
from-clause, ie,
SELECT blah blah blah FROM function-returning-set(arguments) ...
This doesn't require any creative interpretation of SQL semantics
to figure out what to do with the multiple result rows.
BTW, is there a good reason why you don't just use a VIEW?
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, jburton@scw.org
Subject: Re: Can I create a function that returns many records?
In-Reply-To: <22054.964030918@sss.pgh.pa.us>
References: <3975A98C.26157.984840B@localhost> <22054.964030918@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox