Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 852119FB5F2 for ; Wed, 4 Apr 2007 10:07:03 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 10431-02 for ; Wed, 4 Apr 2007 10:06:42 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from web31805.mail.mud.yahoo.com (web31805.mail.mud.yahoo.com [68.142.207.68]) by postgresql.org (Postfix) with SMTP id 5FF809FB5CE for ; Wed, 4 Apr 2007 10:06:47 -0300 (ADT) Received: (qmail 9860 invoked by uid 60001); 4 Apr 2007 13:06:45 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=Ub1ogv5mX/5N0N1r8YB2Ri33Vu9Jk1F0etMN/VEUuRLNp0dEsXGTskBwwIbQemiWK54AG6mDaxdFon3tQzYgYaZHMHOELiF2KltM+85OZi3IG+L9mDxw7SXXnARP8cxmr3ECcI9X6c+3EMDVQV6MzwK+PZHwng4DfMOGHirl8lY=; X-YMail-OSG: JPbaj.UVM1mbdehQAsUMpFWTaKtfgyeTAYcl_R_DvtMFP2kpBqMJ7I0tnNV_eIMIUJU7yN.kWWW6AwVGxe.uD3NYxl_AK35leK7dtvRL3N8r3nPjo9bO8DvAGA-- Received: from [75.84.89.248] by web31805.mail.mud.yahoo.com via HTTP; Wed, 04 Apr 2007 06:06:45 PDT Date: Wed, 4 Apr 2007 06:06:45 -0700 (PDT) From: Richard Broersma Jr Subject: Re: Moving a simple function to pl/pgsql (Novice question) To: Paul Lambert , pgsql-sql@postgresql.org In-Reply-To: <46134373.40504@autoledgers.com.au> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <806297.7462.qm@web31805.mail.mud.yahoo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200704/55 X-Sequence-Number: 28055 --- Paul Lambert wrote: > The purpose being when a row in a table in one database is updated, it > will copy (or replicate I guess) the record into a different table into > another database in the same server. (deleting said record first if it > already exists) > > What is the best way to do this within Postgres? In postgresql, there are two parts to implementing a trigger; the trigger function and the actual trigger on the table that calls this function. Here is a good example: http://www.postgresql.org/docs/8.2/interactive/plpgsql-trigger.html#PLPGSQL-TRIGGER-AUDIT-EXAMPLE One other point to be aware of, Postgresql does not allow your to reference other databases in the DB-cluster directly. It is possible but you need to add a contrib module called dblink: http://pgfoundry.org/projects/snapshot/ Hope this helps, Regards, Richard Broersma Jr.