Re: Functions and transactions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Kris Kiger <kris(at)musicrebellion(dot)com>
Cc: "Pgsql-Admin (E-mail)" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Functions and transactions
Date: 2005-03-09 22:34:01
Message-ID: 7701.1110407641@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-hackers pgsql-patches

Kris Kiger <kris(at)musicrebellion(dot)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

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Subbiah, Stalin 2005-03-10 00:44:23 Schemas to Search_path
Previous Message Tsirkin Evgeny 2005-03-09 21:51:15 Re: Functions and transactions

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Hallgren 2005-03-09 23:03:13 Re: Runtime accepting build discrepancies
Previous Message Tom Lane 2005-03-09 22:22:53 Re: Runtime accepting build discrepancies

Browse pgsql-patches by date

  From Date Subject
Next Message Luiz K. Matsumura 2005-03-10 03:31:56 problem with CR+LF in files in psql \i command
Previous Message Tsirkin Evgeny 2005-03-09 21:51:15 Re: Functions and transactions