From: Tom Lane <tgl@sss.pgh.pa.us>
To: Kris Kiger <kris@musicrebellion.com>
Cc: Pgsql-Admin (E-mail) <pgsql-admin@postgresql.org>
Subject: Re: Functions and transactions
Date: Wed, 09 Mar 2005 17:34:01 -0500
Message-ID: <7701.1110407641@sss.pgh.pa.us> (raw)
In-Reply-To: <422F6203.1090800@musicrebellion.com>
References: <421CF15C.6010306@turtle-entertainment.de>
<421CF1CE.3000800@turtle-entertainment.de>
<422F6203.1090800@musicrebellion.com>
Kris Kiger <kris@musicrebellion.com> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: tgl@sss.pgh.pa.us, kris@musicrebellion.com
Subject: Re: Functions and transactions
In-Reply-To: <7701.1110407641@sss.pgh.pa.us>
References: <421CF15C.6010306@turtle-entertainment.de> <421CF1CE.3000800@turtle-entertainment.de> <422F6203.1090800@musicrebellion.com> <7701.1110407641@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox