Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 269C49FBB5C for ; Wed, 4 Apr 2007 19:20:23 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 31553-04 for ; Wed, 4 Apr 2007 19:20:08 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from rrmailscan3.safenetbox.biz (unknown [203.25.40.75]) by postgresql.org (Postfix) with ESMTP id CAF249FB864 for ; Wed, 4 Apr 2007 19:20:11 -0300 (ADT) Received: from rrmailscan3.safenetbox.biz (rrmailscan3.safenetbox.biz [127.0.0.1]) by rrmailscan3.safenetbox.biz (Postfix) with ESMTP id 349E31D48465 for ; Thu, 5 Apr 2007 08:20:10 +1000 (EST) Received: from [127.0.0.1] (online4-new.lnk.telstra.net [139.130.169.227]) (Authenticated sender: remote) by rrmailscan3.safenetbox.biz (Postfix) with ESMTP id 90BAD1D4844C for ; Thu, 5 Apr 2007 08:20:08 +1000 (EST) Message-ID: <46142491.2080808@autoledgers.com.au> Date: Thu, 05 Apr 2007 06:20:01 +0800 From: Paul Lambert User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Re: Moving a simple function to pl/pgsql (Novice question) References: <806297.7462.qm@web31805.mail.mud.yahoo.com> In-Reply-To: <806297.7462.qm@web31805.mail.mud.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200704/59 X-Sequence-Number: 28059 Richard Broersma Jr wrote: > --- 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. > > ---------------------------(end of broadcast)--------------------------- > TIP 3: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faq > > Perfect, thanks Richard. Regards, Paul. -- Paul Lambert Database Administrator AutoLedgers