From: | Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com> |
---|---|
To: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | "Cast" SRF returning record to a table type? |
Date: | 2015-04-18 00:20:26 |
Message-ID: | 5531A34A.4090909@BlueTreble.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I'm working on a function that will return a set of test data, for unit
testing database stuff. It does a few things, but ultimately returns
SETOF record that's essentially:
RETURN QUERY EXECUTE 'SELECT * FROM ' || table_name;
Because it's always going to return a real relation, I'd like to be able
to the equivalent of:
SELECT ... FROM my_function( 'some_table' )::some_table;
Is there any trick that would allow that to work? I know that instead of
'SELECT * ...' I can do 'SELECT row(t.*) FROM ' || table_name || ' AS t'
and then do
SELECT ... FROM my_function( 'some_table' ) AS data( d some_table )
but I'm hoping to avoid the extra level of indirection.
--
Jim Nasby, Data Architect, Blue Treble Consulting
Data in Trouble? Get it in Treble! http://BlueTreble.com
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2015-04-18 00:39:27 | Re: "Cast" SRF returning record to a table type? |
Previous Message | Adrian Klaver | 2015-04-17 23:16:02 | Re: Running pg_upgrade under Debian |