Re: can a function return a virtual table? - Mailing list pgsql-sql

From Josh Berkus
Subject Re: can a function return a virtual table?
Date
Msg-id 200504231100.56375.josh@agliodbs.com
Whole thread Raw
In response to can a function return a virtual table?  (Kai Hessing <kai.hessing@hobsons.de>)
List pgsql-sql
Kai,

> It would be much nicer to have to write something like: SELECT xyz, abc
> FROM active(tablex); where the function 'active(x)' returns a virtual
> table with all entries from table x where status is > -1. But sadly I
> have no idea how write such a function. Good old O'reilly can't help (or
> i'm to dumb *g*).

http://techdocs.postgresql.org/guides/SetReturningFunctions

Beware, though, that query plan estimation for SRFs is less accurate than for 
regular subqueries, so you could end up with unnecessarily slow query 
execution.  Test!

-- 
Josh Berkus
Aglio Database Solutions
San Francisco


pgsql-sql by date:

Previous
From: "Tadej Kanizar"
Date:
Subject: weird SQL statement question
Next
From: Frank Bax
Date:
Subject: Re: weird SQL statement question