From: | Craig Ringer <craig(at)postnewspapers(dot)com(dot)au> |
---|---|
To: | Mike Christensen <mike(at)kitchenpc(dot)com> |
Cc: | zhong ming wu <mr(dot)z(dot)m(dot)wu(at)gmail(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: return setof : alternatives to holder table |
Date: | 2010-08-15 11:57:56 |
Message-ID: | 4C67D644.9090609@postnewspapers.com.au |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Sandeep Srinivasa | 2010-08-15 12:53:37 | Relationship between ulimit and effective_cache_size, work_mem, shared_buffers, maintenance_work_mem and vacuum |
Previous Message | A. Kretschmer | 2010-08-15 10:20:02 | Re: return setof : alternatives to holder table |