Re: "Cast" SRF returning record to a table type?
| От | Jim Nasby |
|---|---|
| Тема | Re: "Cast" SRF returning record to a table type? |
| Дата | |
| Msg-id | 5532DCA5.40407@BlueTreble.com обсуждение исходный текст |
| Ответ на | Re: "Cast" SRF returning record to a table type? ("David G. Johnston" <david.g.johnston@gmail.com>) |
| Ответы |
Re: "Cast" SRF returning record to a table type?
|
| Список | pgsql-general |
On 4/18/15 12:47 AM, David G. Johnston wrote:
> If you could find a way to pass a value of type some_table into the
> function - instead of the name/text 'some_table‘ - you could possibly
> use polymorphic pseudotypes...just imagining here...
Oh, I didn't think about that. Maybe I'll try it.
What I ended up with is this:
CREATE FUNCTION ... (
) RETURNS SETOF text ...
...
RETURN QUERY EXECUTE format(
'SELECT row(t.*)::text FROM %I.%I AS t'
, ...
);
So the function is getting a record and casting it to text. To call the
function you have to...
SELECT (function(...))::name_of_table).*
that gives you the same output as if you'd selected directly from the table.
--
Jim Nasby, Data Architect, Blue Treble Consulting
Data in Trouble? Get it in Treble! http://BlueTreble.com
В списке pgsql-general по дате отправления: