[SQL] Returning a set from an function

2006-04-08 Thread Keith Hutchison
G'day,

Looking for an example showing how to return a set from either a sql
function or a plpsqq function.

Thanks

--
Keith Hutchison
http://balance-infosystems.com http://realopen.org
http://www.kasamba.com/Keith-Hutchison

---(end of broadcast)---
TIP 5: don't forget to increase your free space map settings


Re: [SQL] Returning a set from an function

2006-04-08 Thread Tom Lane
"Keith Hutchison" <[EMAIL PROTECTED]> writes:
> Looking for an example showing how to return a set from either a sql
> function or a plpsqq function.

Try "SQL Functions Returning Sets" here:
http://www.postgresql.org/docs/8.1/static/xfunc-sql.html

In plpgsql you just "RETURN NEXT" each value (typically this would
be inside a loop, though it doesn't have to be) and then either
RETURN with no argument or fall off the end of the function (I think
the latter is only allowed as of PG 8.1).  There don't seem to be
any very compelling examples in the manual, but I bet you can find
some at techdocs.postgresql.org.

regards, tom lane

---(end of broadcast)---
TIP 2: Don't 'kill -9' the postmaster