pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Franco Bruno Borghesi <franco@akyasociados.com.ar>
To: Tomasz Myrta <jasiek@klaster.net>
To: friedrich nietzsche <nietzsche_psql@yahoo.it>
Cc: pgsql-sql@postgresql.org
Subject: Re: connecting to a differnt DB in PL/pgSQL
Date: Mon, 14 Apr 2003 14:16:08 -0300
Message-ID: <200304141416.08254.franco@akyasociados.com.ar> (raw)
In-Reply-To: <3E9AD77D.6020904@klaster.net>
References: <20030414152903.32560.qmail@web40502.mail.yahoo.com>
	<3E9AD77D.6020904@klaster.net>

you should install dblink as Tomasz said. To do that:

cd ...../postgresql-7.3.2/contrib/dblink
gmake
gmake install

then you enter into psql to create the functions:
\i dblink.psql

then you try (change the params):

SELECT 
    * 
FROM 
    dblink('host=localhost port=5432 dbname=franco user=admin password=1234', 
'SELECT id, name FROM people') 
    AS (id INTEGER, people TEXT);

If you skip the values host, port, ..., the defaults will be used.
If it works in psql, it should work inside a function.




On Monday 14 April 2003 12:45, Tomasz Myrta wrote:
> Uz.ytkownik friedrich nietzsche napisa?:
> > Hi all,
> > Is it possible to connect to another database within a
> > PL/PgSQL function?
> >
> > I'm in a function on the "A" database and I need to
> > retrieve some information from a table in a different
> > Database "B"
> >
> > may someone help me?
> >
> > thanks, Danilo.
> > bye.
>
> You can't access another database even inside 1 server directly.
> Find something about contrib/dblink - maybe it will help you.
>
> Regards,
> Tomasz Myrta
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster

view thread (4+ messages)  latest in thread

Message-ID: <200304141416.08254.franco@akyasociados.com.ar>
Permalink:  ../200304141416.08254.franco@akyasociados.com.ar/
Also on:    postgresql.org/message-id/200304141416.08254.franco@akyasociados.com.ar

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: franco@akyasociados.com.ar, jasiek@klaster.net, nietzsche_psql@yahoo.it
  Subject: Re: connecting to a differnt DB in PL/pgSQL
  In-Reply-To: <200304141416.08254.franco@akyasociados.com.ar>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox