Discussion:
'dblink' Help
(too old to reply)
JinNet Picker
2004-01-27 10:53:26 UTC
Permalink
Hi,

I have Two databases names 'MyDb1' and 'MyDb2' in My
System.

I have installed Postgres 7.4 with dblink

What i need is, when ever a NEW record is inserted in
'MyDb1' , i want fire a Trigger or Rule to insert the
Same Record to MyDb2 database.

I am Using MAC OS 10.2

Anybody Got Idea how to do this?

Thanks



----------------------------------------------
Some Sample Query Using "dblink" is:
select * from dblink('hostaddr=192.168.1.1
dbname=MyDb1 user=pgsql','select
username,password,usertype from users') as t1(username
varchar,password varchar,usertype varchar);

----------------------------------------------

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ***@postgresql.org
Joe Conway
2004-01-31 19:38:22 UTC
Permalink
Post by JinNet Picker
What i need is, when ever a NEW record is inserted in
'MyDb1' , i want fire a Trigger or Rule to insert the
Same Record to MyDb2 database.
Anybody Got Idea how to do this?
See the dblink documentation for dblink_exec(), and see the Postgres
documentation for how to create triggers:
http://www.postgresql.org/docs/current/static/triggers.html
You'll probably want to create the trigger function using PL/pgSQL:
http://www.postgresql.org/docs/current/static/plpgsql.html

Joe



---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Loading...