X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 97D1B555C1 for ; Wed, 9 Mar 2005 22:34:13 +0000 (GMT) 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 73913-02 for ; Wed, 9 Mar 2005 22:34:04 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id D10765516A for ; Wed, 9 Mar 2005 22:34:03 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j29MY1Yl007702; Wed, 9 Mar 2005 17:34:01 -0500 (EST) To: Kris Kiger Cc: "Pgsql-Admin (E-mail)" Subject: Re: Functions and transactions In-reply-to: <422F6203.1090800@musicrebellion.com> References: <421CF15C.6010306@turtle-entertainment.de> <421CF1CE.3000800@turtle-entertainment.de> <422F6203.1090800@musicrebellion.com> Comments: In-reply-to Kris Kiger message dated "Wed, 09 Mar 2005 15:52:19 -0500" Date: Wed, 09 Mar 2005 17:34:01 -0500 Message-ID: <7701.1110407641@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200503/138 X-Sequence-Number: 16636 Kris Kiger writes: > Here is my problem. I have a function that is triggered on insert. For > simplicity's sake, lets say the function looks like this: > CREATE OR REPLACE FUNCTION dostuff_on_insert() RETURNS TRIGGER AS ' > DECLARE lockrows RECORD; > BEGIN > select into lockrows * from table1 where pkey_id = NEW.pkey_id for > update on table1; > update table1 set active = false where NEW.pkey_id = pkey_id and active; > NEW.active := true; > END; > 'language 'plpgsql'; This is awfully vague. What table is the trigger placed on? (If table1 itself, seems like there are more efficient ways to do this.) What events is the trigger fired for, and is it BEFORE or AFTER? regards, tom lane