Search Postgresql Archives

Re: return setof : alternatives to holder table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 15/08/2010 6:18 PM, Mike Christensen wrote:

How about just using OUT parameters?

CREATE FUNCTION FOO(IN _id uuid, OUT col1 text, OUT col2 text)
    RETURNS SETOF record AS
    BEGIN
       select col1, col2 from test where id=_id;
    END;

Then your output just has to match the signature of the OUT parameters.
  And you don't need to define anything when you call it.

That works - and in fact is what I often do. For a couple of functions I have a little query that re-generates the OUT param lists based on the contents of the INFORMATION_SCHEMA for those tables and dynamically re-creates the function, too.

It'd be kind of nice to have ALTERing a table propagate that sort of change to dependent functions so it didn't have to be manually maintained. Given that it doesn't do that for even views at the momement, though, it'd a pretty minor thing, and after development slows down post-release schema don't tend to change that fast anyway.

--
Craig Ringer

--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux