X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E15FF52E14 for ; Mon, 15 Aug 2005 00:13:04 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 54587-08 for ; Mon, 15 Aug 2005 03:13:01 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id 09E8552975 for ; Mon, 15 Aug 2005 00:12:59 -0300 (ADT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j7F3Cp7m003028 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 14 Aug 2005 21:12:53 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j7F3CoDb095531; Sun, 14 Aug 2005 21:12:50 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j7F3Cobx095530; Sun, 14 Aug 2005 21:12:50 -0600 (MDT) (envelope-from mfuhr) Date: Sun, 14 Aug 2005 21:12:50 -0600 From: Michael Fuhr To: Haris Saybasili Cc: pgsql-sql@postgresql.org Subject: Re: trigger between to different database Message-ID: <20050815031250.GA93409@winnie.fuhr.org> References: <685abb830508081141386a3878@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <685abb830508081141386a3878@mail.gmail.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 required=5 tests=[AWL=0.005] X-Spam-Level: X-Archive-Number: 200508/88 X-Sequence-Number: 22316 On Mon, Aug 08, 2005 at 09:41:22PM +0300, Haris Saybasili wrote: > > I have two databasese: database1 and database2. I want to set a > trigger on a table of database1 which will insert some values to a > table of database2. You could use contrib/dblink but you wouldn't have transaction semantics. For example, suppose you insert a record into database1 and the trigger inserts a record into database2. If you then roll back the transaction in database1, there's no simple way to roll back the changes in database2. Another possibility would be to use LISTEN/NOTIFY, which does work with transactions (NOTIFY messages aren't sent until and unless the transaction commits). But this has problems too: you have to find out what record(s) to insert, and what should happen if the insert in database2 fails? Should the changes in database1 be rolled back somehow, even though they've already been committed? Do you really need separate databases? The problems described above would go away if you used multiple schemas in the same database instead of multiple databases. -- Michael Fuhr