X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3C90347610C for ; Mon, 14 Apr 2003 13:15:15 -0400 (EDT) Received: from lucifer.akyasociados.com.ar (unknown [200.69.203.237]) by postgresql.org (Postfix) with ESMTP id 25FC6475CE5 for ; Mon, 14 Apr 2003 13:15:14 -0400 (EDT) Received: from taz.oficina (taz.oficina [192.168.1.197]) (authenticated bits=0) by lucifer.akyasociados.com.ar (8.12.8/8.12.8) with ESMTP id h3EHIKeS039249; Mon, 14 Apr 2003 14:18:21 -0300 (ART) (envelope-from franco@akyasociados.com.ar) From: Franco Bruno Borghesi Organization: AK y Asociados S.R.L. To: Tomasz Myrta , friedrich nietzsche Subject: Re: connecting to a differnt DB in PL/pgSQL Date: Mon, 14 Apr 2003 14:16:08 -0300 User-Agent: KMail/1.5 Cc: pgsql-sql@postgresql.org References: <20030414152903.32560.qmail@web40502.mail.yahoo.com> <3E9AD77D.6020904@klaster.net> In-Reply-To: <3E9AD77D.6020904@klaster.net> MIME-Version: 1.0 Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg=pgp-sha1; boundary="Boundary-02=_Yzum+DCjn5AIMdD"; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200304141416.08254.franco@akyasociados.com.ar> X-Spam-Status: No, hits=-38.8 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,PGP_SIGNATURE_2, QUOTED_EMAIL_TEXT,REFERENCES,REPLY_WITH_QUOTES,USER_AGENT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/210 X-Sequence-Number: 12911 --Boundary-02=_Yzum+DCjn5AIMdD Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Description: signed data Content-Disposition: inline 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=20 *=20 FROM=20 dblink('host=3Dlocalhost port=3D5432 dbname=3Dfranco user=3Dadmin passw= ord=3D1234',=20 'SELECT id, name FROM people')=20 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 --Boundary-02=_Yzum+DCjn5AIMdD Content-Type: application/pgp-signature Content-Description: signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (FreeBSD) iD8DBQA+muzYz/PwDAvtu7oRAnUUAJ44nKIJdc47pumVbGJFa094CsScgQCeNwma VZbGL6+XnRLwMaRThgYWFIQ= =eLoY -----END PGP SIGNATURE----- --Boundary-02=_Yzum+DCjn5AIMdD--