pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
connecting to a differnt DB in PL/pgSQL
4+ messages / 3 participants
[nested] [flat]

* connecting to a differnt DB in PL/pgSQL
@ 2003-04-14 15:29 friedrich nietzsche <nietzsche_psql@yahoo.it>
  2003-04-14 15:45 ` Re: connecting to a differnt DB in PL/pgSQL Tomasz Myrta <jasiek@klaster.net>
  0 siblings, 1 reply; 4+ messages in thread

From: friedrich nietzsche @ 2003-04-14 15:29 UTC (permalink / raw)
  To: pgsql-sql

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.

______________________________________________________________________
Yahoo! Cellulari: loghi, suonerie, picture message per il tuo telefonino
http://it.yahoo.com/mail_it/foot/?http://it.mobile.yahoo.com/index2002.html




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: connecting to a differnt DB in PL/pgSQL
  2003-04-14 15:29 connecting to a differnt DB in PL/pgSQL friedrich nietzsche <nietzsche_psql@yahoo.it>
@ 2003-04-14 15:45 ` Tomasz Myrta <jasiek@klaster.net>
  2003-04-14 17:16   ` Re: connecting to a differnt DB in PL/pgSQL Franco Bruno Borghesi <franco@akyasociados.com.ar>
  0 siblings, 1 reply; 4+ messages in thread

From: Tomasz Myrta @ 2003-04-14 15:45 UTC (permalink / raw)
  To: friedrich nietzsche <nietzsche_psql@yahoo.it>; +Cc: pgsql-sql

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




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: connecting to a differnt DB in PL/pgSQL
  2003-04-14 15:29 connecting to a differnt DB in PL/pgSQL friedrich nietzsche <nietzsche_psql@yahoo.it>
  2003-04-14 15:45 ` Re: connecting to a differnt DB in PL/pgSQL Tomasz Myrta <jasiek@klaster.net>
@ 2003-04-14 17:16   ` Franco Bruno Borghesi <franco@akyasociados.com.ar>
  2003-04-16 07:54     ` Re: connecting to a differnt DB in PL/pgSQL friedrich nietzsche <nietzsche_psql@yahoo.it>
  0 siblings, 1 reply; 4+ messages in thread

From: Franco Bruno Borghesi @ 2003-04-14 17:16 UTC (permalink / raw)
  To: Tomasz Myrta <jasiek@klaster.net>; friedrich nietzsche <nietzsche_psql@yahoo.it>; +Cc: pgsql-sql

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

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: connecting to a differnt DB in PL/pgSQL
  2003-04-14 15:29 connecting to a differnt DB in PL/pgSQL friedrich nietzsche <nietzsche_psql@yahoo.it>
  2003-04-14 15:45 ` Re: connecting to a differnt DB in PL/pgSQL Tomasz Myrta <jasiek@klaster.net>
  2003-04-14 17:16   ` Re: connecting to a differnt DB in PL/pgSQL Franco Bruno Borghesi <franco@akyasociados.com.ar>
@ 2003-04-16 07:54     ` friedrich nietzsche <nietzsche_psql@yahoo.it>
  0 siblings, 0 replies; 4+ messages in thread

From: friedrich nietzsche @ 2003-04-16 07:54 UTC (permalink / raw)
  To: pgsql-sql

Avevo gia' risolto il come farlo,
ma grazie lo stesso
Ciao
Danilo


 --- Franco Bruno Borghesi
<franco@akyasociados.com.ar> ha scritto: > 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.
> 
> 
> 
> 


______________________________________________________________________
Yahoo! Cellulari: loghi, suonerie, picture message per il tuo telefonino
http://it.yahoo.com/mail_it/foot/?http://it.mobile.yahoo.com/index2002.html




^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2003-04-16 07:54 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-04-14 15:29 connecting to a differnt DB in PL/pgSQL friedrich nietzsche <nietzsche_psql@yahoo.it>
2003-04-14 15:45 ` Tomasz Myrta <jasiek@klaster.net>
2003-04-14 17:16   ` Franco Bruno Borghesi <franco@akyasociados.com.ar>
2003-04-16 07:54     ` friedrich nietzsche <nietzsche_psql@yahoo.it>

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