Re: Preserving datatypes in dblink. - Mailing list pgsql-admin

From Joe Conway
Subject Re: Preserving datatypes in dblink.
Date
Msg-id 3D699D8A.6090500@joeconway.com
Whole thread Raw
In response to Re: Preserving datatypes in dblink.  (Bhuvan A <bhuvansql@linuxfreemail.com>)
List pgsql-admin
Bhuvan A wrote:
> Yeah, I did try the same earlier but it says
> ERROR:  Cannot cast type 'text' to 'text[]'
>
> So how do we cast text to text[](_text)? Is there any alternate way?
> Awaiting for your valuable suggestion again, please.

Hmmm. I see what you mean. I'm afraid there may be no way to return an
array via dblink currently :(

I am just starting the next upgrade to dblink to support table functions
in PostgreSQL 7.3 (which starts beta testing around September 1). Table
functions should make dblink work much more naturally, something like
(not yet working, but hopefully should be by next weekend on 7.3devel):

select
  d.f1, d.f2
from
  dblink('dbname=mydb', 'select f1, f2 from remotetbl')
  as d(f1 int, f2 text);

This would return f1 as an int, and f2 as text without the need to cast
them in the target list. I would think that arrays would return fine
this way, but I'll check as I'm working on it.

Joe


pgsql-admin by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Backup and Recovery (revisited)
Next
From: Curt Sampson
Date:
Subject: Re: how to determine the hardware I need