Re: arrays of rows and dblink - Mailing list pgsql-general

From David G Johnston
Subject Re: arrays of rows and dblink
Date
Msg-id 1398881940648-5802050.post@n5.nabble.com
Whole thread Raw
In response to arrays of rows and dblink  (Torsten Förtsch <torsten.foertsch@gmx.net>)
Responses Re: arrays of rows and dblink  (Torsten Förtsch <torsten.foertsch@gmx.net>)
List pgsql-general
Torsten Förtsch wrote
> Hi,
>
> we have the ROW type and we have arrays. We also can create arrays of
> rows like:
>
> select array_agg(r)
>   from (values (1::int, 'today'::timestamp, 'a'::text),
>                (2, 'yesterday', 'b')) r(a,b,c);
>                              array_agg
> -------------------------------------------------------------------
>  {"(1,\"2014-04-30 00:00:00\",a)","(2,\"2014-04-29 00:00:00\",b)"}
>
>
> Now I want to execute that query via dblink on a remote server. How do I
> specify the result type?
>
> select tb.* from dblink( 'dbname=postgres', $$
>     select array_agg(r)
>       from (values (1::int, 'today'::timestamp, 'a'::text),
> $$) tb( WHAT DO I PUT HERE? )
>
> Thanks,
> Torsten

ISTM that you have to "CREATE TYPE ..." as appropriate then

... tb ( col_alias type_created_above[] )

There is only so much you can do with anonymous types (which is what the ROW
construct creates; ROW is not a type but an expression anchor - like
ARRAY[...]) that tells the parser how to interpret what follows.

David J.




--
View this message in context: http://postgresql.1045698.n5.nabble.com/arrays-of-rows-and-dblink-tp5802035p5802050.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


pgsql-general by date:

Previous
From: Torsten Förtsch
Date:
Subject: arrays of rows and dblink
Next
From: Torsten Förtsch
Date:
Subject: Re: arrays of rows and dblink