Search Postgresql Archives

Re: Insert into other database

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Feb 08, 2006 at 05:59:19PM -0400, Rodolfo Campos wrote:
> I'm wondering if in postgres we can insert a tuple into a table that is
> outside of a database (I'm supossed to be connected to database1 and want to
> insert a register into a table in database2).

You can do this with contrib/dblink; search the list archives for
other possibilities (PL/Perl + DBI + DBD::Pg, dbi-link, etc.).

> This question is because I want to update a tables into one database from a
> trigger (written in C), and the table who fires the trigger is in another
> database.

A C function can use libpq to connect to another database; that's
how dblink works.  But such a design is often a hint to consider
using separate schemas in the same database rather than separate
databases.  A problem with actions that take place outside the
current database is that you lose transactional control: if the
triggering transaction rolls back then you have no way to roll back
the outside changes.

-- 
Michael Fuhr


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux