Unix Technical Forum

creating a trigger to access another postgres database?

This is a discussion on creating a trigger to access another postgres database? within the Pgsql General forums, part of the PostgreSQL category; --> I have a question regarding postgres Trigger. We have two applications which connect to two different databases (Both are ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql General

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-09-2008, 11:23 PM
carty mc
 
Posts: n/a
Default creating a trigger to access another postgres database?

I have a question regarding postgres Trigger.
We have two applications which connect to two different databases (Both are postgres).
Is it possible to create a trigger (row based) in one database say A, which can access another database say B and updates a table there.

In brief, Is it possible to create Trigger in one database, which can connect to another database for making an update in the other database table.

thanks,


---------------------------------
Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-09-2008, 11:23 PM
Richard Huxton
 
Posts: n/a
Default Re: creating a trigger to access another postgres database?

carty mc wrote:
> I have a question regarding postgres Trigger. We have two
> applications which connect to two different databases (Both are
> postgres). Is it possible to create a trigger (row based) in one
> database say A, which can access another database say B and updates a
> table there.


Sure - check the manuals (in 8.3) for dblink - it's in contrib. It's
been there for a while, but the documentation for contrib modules wasn't
in the manual until 8.3

--
Richard Huxton
Archonet Ltd

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-09-2008, 11:23 PM
carty mc
 
Posts: n/a
Default Re: creating a trigger to access another postgres database?

Thanks Richard,
I went through dblink and tried it . But I am not able to pass variables to sql stmt of dblink_exec function . Basically If I hardcode the values for updating a table for the sql statement in different database it is working fine. But What I wanted to do is get the info from existing modified row and pass that into the update query which I am writing inside dblink_exec call.

my sql inside dblink_exec call would look like
UPDATE my_table set myotherDBTableField = NEW.currDBTableField WHERE {condition}

When the trigger function executes this it is giving an error some Rule need to be set.
Whereas If I hardcode that value instead of using NEW.xxxx it is working fine?

I appreciate any insights,

thanks,



Richard Huxton <dev@archonet.com> wrote:
carty mc wrote:
> I have a question regarding postgres Trigger. We have two
> applications which connect to two different databases (Both are
> postgres). Is it possible to create a trigger (row based) in one
> database say A, which can access another database say B and updates a
> table there.


Sure - check the manuals (in 8.3) for dblink - it's in contrib. It's
been there for a while, but the documentation for contrib modules wasn't
in the manual until 8.3

--
Richard Huxton
Archonet Ltd



---------------------------------
No Cost - Get a month of Blockbuster Total Access now. Sweet deal for Yahoo! users and friends.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 12:31 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com