triggers/functions across databases

Started by Eric Jonesalmost 21 years ago6 messagesgeneral
Jump to latest
#1Eric Jones
Eric.Jones@noaa.gov

We are migrating from Informix to Postgres 7.4.7 and are having a
difficult time finding if postgres can insert/update tables across
different databases. Namely using functions/triggers when an
update/insert is performed on a table it updates/inserts in a table on a
different database. Informix can do this with no problem but we were
wondering if there is an easy way for postgres to do this. I've searched
numerous sites and found vague answers. Thanks in advance.

Eric Jones

#2Scott Marlowe
smarlowe@g2switchworks.com
In reply to: Eric Jones (#1)
Re: triggers/functions across databases

On Wed, 2005-05-25 at 07:08, Eric Jones wrote:

We are migrating from Informix to Postgres 7.4.7 and are having a
difficult time finding if postgres can insert/update tables across
different databases. Namely using functions/triggers when an
update/insert is performed on a table it updates/inserts in a table on a
different database. Informix can do this with no problem but we were
wondering if there is an easy way for postgres to do this. I've searched
numerous sites and found vague answers. Thanks in advance.

Could you solve this problem using schemas in one database? OR do you
need the data to be in two physically separate locations? If so, you
might be better off using listen / notify between the two databases, or
using an external program to begin transactions in both places and
commit or roll them back together.

#3Richard Huxton
dev@archonet.com
In reply to: Eric Jones (#1)
Re: triggers/functions across databases

Eric Jones wrote:

We are migrating from Informix to Postgres 7.4.7 and are having a
difficult time finding if postgres can insert/update tables across
different databases. Namely using functions/triggers when an
update/insert is performed on a table it updates/inserts in a table on a
different database. Informix can do this with no problem but we were
wondering if there is an easy way for postgres to do this. I've searched
numerous sites and found vague answers. Thanks in advance.

If in doubt, check the manuals or contact the list.

The short answer is "no" - you can query across schemas but not across
databases.

The long answer is "maybe" - check the contrib/dblink package (in the
source distribution). That can query another database on the same or
different machine.

--
Richard Huxton
Archonet Ltd

#4Joshua D. Drake
jd@commandprompt.com
In reply to: Eric Jones (#1)
Re: triggers/functions across databases

Eric Jones wrote:

We are migrating from Informix to Postgres 7.4.7 and are having a
difficult time finding if postgres can insert/update tables across
different databases. Namely using functions/triggers when an
update/insert is performed on a table it updates/inserts in a table on a
different database. Informix can do this with no problem but we were
wondering if there is an easy way for postgres to do this. I've searched
numerous sites and found vague answers. Thanks in advance.

If you have databases that are dependent on each others data you should
probably move those databases into a new schema within one database...

See the create schema command.

Otherwise you could use dblink but it would not be my suggestion.

Sincerely,

Joshua D. Drake

Eric Jones

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

--
Your PostgreSQL solutions company - Command Prompt, Inc. 1.800.492.2240
PostgreSQL Replication, Consulting, Custom Programming, 24x7 support
Managed Services, Shared and Dedicated Hosting
Co-Authors: plPHP, plPerlNG - http://www.commandprompt.com/

#5Mike Nolan
nolan@gw.tssi.com
In reply to: Joshua D. Drake (#4)
Re: triggers/functions across databases

If you have databases that are dependent on each others data you should
probably move those databases into a new schema within one database...

That's a non-trivial task, especially if some of the tables in the
two databases have the same name.
--
Mike Nolan

#6Joshua D. Drake
jd@commandprompt.com
In reply to: Mike Nolan (#5)
Re: triggers/functions across databases

Mike Nolan wrote:

If you have databases that are dependent on each others data you should
probably move those databases into a new schema within one database...

That's a non-trivial task, especially if some of the tables in the
two databases have the same name.

Migrating from one database to another database is a non trivial task as
a whole :)

--
Mike Nolan

--
Your PostgreSQL solutions company - Command Prompt, Inc. 1.800.492.2240
PostgreSQL Replication, Consulting, Custom Programming, 24x7 support
Managed Services, Shared and Dedicated Hosting
Co-Authors: plPHP, plPerlNG - http://www.commandprompt.com/