Thread: Calling a table residing in another database from Plpgsql

Calling a table residing in another database from Plpgsql

From
deepthi@granwill.com
Date:
Hi,

I have function called test1() in database 1. I need to input the value
from this function into another table which is in database2.

How can i achieve this task in plpgsql. I went through some documentation
and found out that it is possible through dblink.

I infact downloaded the dblink package in contrib folder. But still when i
tried to use dblink in the following manner:

SELECT * from dblink('host=192.168.0.50 dbname=AK1 user=akteam','Select
userid from user_reg') as t (userid integer);

I am getting an error as "ERROR:  function dblink("unknown", "unknown")
does not exist"

Is dblink the only way of connecting the databases and if so what is the
exact step by step procedure to be follwed to download dblink and use it
to connect databases.

Thanks in advance,
Regards,
deepthi








Re: Calling a table residing in another database from Plpgsql

From
Kenneth Gonsalves
Date:
On Wednesday 05 January 2005 10:43 am, deepthi@granwill.com wrote:
> Hi,
>
> I have function called test1() in database 1. I need to input the value
> from this function into another table which is in database2.

shouldnt you be using schemas instead?

kg


Re: Calling a table residing in another database from Plpgsql

From
Joe Conway
Date:
deepthi@granwill.com wrote:
> SELECT * from dblink('host=192.168.0.50 dbname=AK1 user=akteam','Select
> userid from user_reg') as t (userid integer);
> 
> I am getting an error as "ERROR:  function dblink("unknown", "unknown")
> does not exist"

Have you installed the dblink functions into your database? See 
README.dblink.

Joe



Re: Calling a table residing in another database from Plpgsql

From
Kretschmer Andreas
Date:
am  Tue, dem 04.01.2005, um 21:13:46 -0800 mailte deepthi@granwill.com folgendes:
> Hi,
> 
> I have function called test1() in database 1. I need to input the value
> from this function into another table which is in database2.
> 
> How can i achieve this task in plpgsql. I went through some documentation
> and found out that it is possible through dblink.
> 
> I infact downloaded the dblink package in contrib folder. But still when i
> tried to use dblink in the following manner:

You must run the dblink.sql, not only download.


Regards, Andreas
-- 
Diese Message wurde erstellt mit freundlicher Unterstützung eines freilau-
fenden Pinguins aus artgerechter Freilandhaltung.   Er ist garantiert frei
von Micro$oft'schen Viren. (#97922 http://counter.li.org)     GPG 7F4584DA
Was, Sie wissen nicht, wo Kaufbach ist? Hier: N 51.05082°, E 13.56889° ;-)


Re: Calling a table residing in another database from Plpgsql

From
CoL
Date:
hi,

deepthi@granwill.com wrote, On 1/5/2005 06:13:
> I infact downloaded the dblink package in contrib folder. But still when i
> tried to use dblink in the following manner:
> 
> SELECT * from dblink('host=192.168.0.50 dbname=AK1 user=akteam','Select
> userid from user_reg') as t (userid integer);
> 
> I am getting an error as "ERROR:  function dblink("unknown", "unknown")
> does not exist"

try to set up dblink. Read the README.dblink file, Installation: part.
Use dblink_connect to connect, then you can query with dblink()

read the docs befor you try to use it.

PS: or better use schemas, not different databases.

C.