Search Postgresql Archives

Re: arrays of rows and dblink

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

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 04/30/2014 12:52 PM, 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? )

select * from dblink('dbname=test',$$select array_agg(r) from (values
(1::int, 'today'::timestamp, 'a'::text), (2, 'yesterday', 'b'))
r(a,b,c)$$) as d(f text[]);
                                 f
- -------------------------------------------------------------------
 {"(1,\"2014-04-30 00:00:00\",a)","(2,\"2014-04-29 00:00:00\",b)"}
(1 row)

HTH,

Joe




- -- 
Joe Conway
credativ LLC: http://www.credativ.us
Linux, PostgreSQL, and general Open Source
Training, Service, Consulting, & 24x7 Support
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.14 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBAgAGBQJTYX7vAAoJEDfy90M199hl7/AQAICrBJILdmvO0Yut+nB+WLzX
f2zFQWbavnM+NTB0oCTCAm5u8ivadrSPJbOc+tXUZ9HNS+RLTwhH4e4WEbW/xoVy
yMJQH17tMKtk11huL08YvqyVTg5fafDcpUZ9I64u6S0jTHx8q1+um9iq2D/ssSkI
xu5AF1YYRHFdLPJ0ifIMEi20ArxZb1BKo8EXi+EiW7ZGhX5LE24Q4CjrUdTeQZyq
u3kwmZwkLni7ISgJqR9ChXo3KiOTprPZD2uejuQr3ivL8addCVVMDq6EAa7S0a/i
Uff/P/HQyfgs5pNhBq0JR6ReoRE2B6Fmx2z/5VGctaNu23694nmJjH5xr9GeZT/G
UXDBUUCQCX+ryErwQg0P2TjwiTp40BcZeuLpgBzHdep+LVcU/I/3zB5GrJz3ujLk
BrzRGSr6FTxi4PGf88wDnFJ0c10pls9tdW1krPHE369eSBNIQbOx9Gh24tfG3meR
iqW5JarWAENB9yhVOAQDFJVp6+P+80UuHOICLXsk2Pd6S4ExtolsSkC+HXDYQTLg
rbMGhgKlrACkSw8IX0lGjg/P1PnZkFjrMRVmXgZi6kK1YvFX19bU2czy9XHKEoLK
Zq1U4hgS8xiyvglYrJpEuX7hs3l84zSpPyjIWGka7KAjRAxq6QwsgtEw8EACoadf
/o3oEbxraYEDN5m8Dns4
=M8Hv
-----END PGP SIGNATURE-----


-- 
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