How To Connect to another Database inside a plpgsql function
--0-1584588277-1076662615=:67415
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
X-MIME-Autoconverted: from 8bit to quoted-printable by zippy.ims.net id i1D8wG818632
Hi Guys!
I have 2 database namely "DB1" and "DB2".
In DB1 I created a plgpsql function fnTest().
My problem is inside fnTest() I need to check some tables in DB2! I've no=
idea how to do this. Usually when I make a function I only access tables=
/views/functions in the same database. I really don't know if this is pos=
sible.
BTW, I googled my problem but did not see any topics on this.
Need your expertise on this one guys...TIA!
Marie Gezeala M. Bacu=F1o II
IS Department
Muramoto Audio-Visual Phils., Inc.
MEPZ1, Lapu-Lapu City, Cebu, Philippines 6015
The person with the ultimate cachinnation possesses, thereby, the optimal=
cachinnation.
---------------------------------
Yahoo! Messenger - Communicate instantly..."Ping" your friends today! D=
ownload Messenger Now
--0-1584588277-1076662615=:67415
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
X-MIME-Autoconverted: from 8bit to quoted-printable by zippy.ims.net id i1D8wG818632
<DIV>Hi Guys!</DIV>
<DIV> </DIV>
<DIV>I have 2 database namely "DB1" and "DB2".</DIV>
<DIV> </DIV>
<DIV>In DB1 I created a plgpsql function fnTest().</DIV>
<DIV> </DIV>
<DIV>My problem is inside fnTest() I need to check some ta=
bles in DB2! I've no idea how to do this. Usually when I make a func=
tion I only access tables/views/functions in the same database. I re=
ally don't know if this is possible.</DIV>
<DIV> </DIV>
<DIV>BTW, I googled my problem but did not see any topics on this.</DIV>
<DIV> </DIV>
<DIV>Need your expertise on this one guys...TIA!</DIV><BR><BR><DIV>
<P><FONT face=3Dverdana><FONT size=3D1><STRONG><FONT color=3D#ff7f00>Mari=
e Gezeala M. Bacu=F1o II <A href=3D"http://www.gezeala.tk/"></A></FONT><B=
R></STRONG><FONT color=3D#4040ff><STRONG>IS Department<BR>Muramoto Audio-=
Visual Phils., Inc.<BR>MEPZ1, Lapu-Lapu City, Cebu, Philippines 6015<BR><=
/STRONG></FONT></FONT></FONT></P>
<P><FONT face=3Dverdana color=3D#40007f size=3D1><STRONG>The person with =
the ultimate cachinnation possesses, thereby, the optimal cachinnation.<B=
R><A href=3D"http://www.gezeala.tk/"></A></STRONG></FONT></P></DIV><p><hr=
size=3D1><font face=3D"Arial" size=3D"2"> <a href=3D"http://uk.rd.yahoo.=
com/mail/tagline_messenger/*http://uk.messenger.yahoo.com"><b>
Yahoo! Messenger</b></a> - Communicate instantly..."Ping" your friends
today! <a href=3D"http://uk.rd.yahoo.com/mail/tagline_messenger/*http://u=
k.messenger.yahoo.com/download/index.html"><strong>Download Messenger Now=
</strong></a></font>
--0-1584588277-1076662615=:67415--
Re: How To Connect to another Database inside a plpgsql function
Gezeala 'Eyah' Bacu=F1o II wrote:
> Hi Guys!
>
> I have 2 database namely "DB1" and "DB2".
>
> In DB1 I created a plgpsql function fnTest().
>
> My problem is inside fnTest() I need to check some tables in DB2! I've
> no idea how to do this. Usually when I make a function I only access
> tables/views/functions in the same database. I really don't know if
> this is possible.
>
Take a look at contrib/dblink, it allows cross database queries like this=
:
SELECT *
FROM
dblink('host=3Dmyhost dbname=3DDB1 user=3Dme',
'SELECT col1, col2, col3
FROM mytable')
AS t (col1 integer, col2 text, col3 real);
--
Mark Gibson <gibsonm |AT| cromwell |DOT| co |DOT| uk>
Web Developer & Database Admin
Cromwell Tools Ltd.
Leicester, England.
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster
Re: How To Connect to another Database inside a plpgsql function
--0-639861131-1076896254=:61514
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
X-MIME-Autoconverted: from 8bit to quoted-printable by hosting.commandprompt.com id i1G1soL24525
Sir, I would really appreciate it if you can please expound more on how t=
o issue a "connect" inside a plpgsql function??
Daghang Salamat sa iyong prompt reply..
I apologize for the late reply kase wala kaming work last saturday.
BTW, I'm not that good in bisaya that's why combination ng bisaya, tagalo=
g and english ang reply ko ;)
Manuel Cabido <manny [at] tinago.msuiit.edu.ph> wrote:
Hi Eyah,
Try daw ug issue ug "connect" to db2 within your procedure in db1.
Manny
Marie Gezeala M. Bacu=F1o II
IS Department
Muramoto Audio-Visual Phils., Inc.
MEPZ1, Lapu-Lapu City, Cebu, Philippines 6015
The person with the ultimate cachinnation possesses, thereby, the optimal=
cachinnation.
---------------------------------
Yahoo! Messenger - Communicate instantly..."Ping" your friends today! D=
ownload Messenger Now
--0-639861131-1076896254=:61514
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
X-MIME-Autoconverted: from 8bit to quoted-printable by hosting.commandprompt.com id i1G1soL24525
<DIV>Sir, I would really appreciate it if you can please expound more on =
how to issue a "connect" inside a plpgsql function??</DIV>
<DIV> </DIV>
<DIV>Daghang Salamat sa iyong prompt reply..</DIV>
<DIV> </DIV>
<DIV>I apologize for the late reply kase wala kaming work last saturday.<=
/DIV>
<DIV><BR>BTW, I'm not that good in bisaya that's why combination ng bisay=
a, tagalog and english ang reply ko ;)</DIV>
<DIV><BR><B><I>Manuel Cabido <manny [at] tinago.msuiit.edu.ph></I></B> w=
rote:</DIV>
<BLOCKQUOTE class=3Dreplbq style=3D"PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #1010ff 2px solid">Hi Eyah,<BR><BR>Try daw ug issue ug "conn=
ect" to db2 within your procedure in db1.<BR><BR>Manny<BR><BR></BLOCKQUOT=
E><BR><BR><DIV>
<P><FONT face=3Dverdana><FONT size=3D1><STRONG><FONT color=3D#ff7f00>Mari=
e Gezeala M. Bacu=F1o II <A href=3D"http://www.gezeala.tk/"></A></FONT><B=
R></STRONG><FONT color=3D#4040ff><STRONG>IS Department<BR>Muramoto Audio-=
Visual Phils., Inc.<BR>MEPZ1, Lapu-Lapu City, Cebu, Philippines 6015<BR><=
/STRONG></FONT></FONT></FONT></P>
<P><FONT face=3Dverdana color=3D#40007f size=3D1><STRONG>The person with =
the ultimate cachinnation possesses, thereby, the optimal cachinnation.<B=
R><A href=3D"http://www.gezeala.tk/"></A></STRONG></FONT></P></DIV><p><hr=
size=3D1><font face=3D"Arial" size=3D"2"> <a href=3D"http://uk.rd.yahoo.=
com/mail/tagline_messenger/*http://uk.messenger.yahoo.com"><b>
Yahoo! Messenger</b></a> - Communicate instantly..."Ping" your friends
today! <a href=3D"http://uk.rd.yahoo.com/mail/tagline_messenger/*http://u=
k.messenger.yahoo.com/download/index.html"><strong>Download Messenger Now=
</strong></a></font>
--0-639861131-1076896254=:61514--