Re: Functions and transactions - Mailing list pgsql-admin

From Tom Lane
Subject Re: Functions and transactions
Date
Msg-id 7701.1110407641@sss.pgh.pa.us
Whole thread Raw
In response to Functions and transactions  (Kris Kiger <kris@musicrebellion.com>)
Responses Re: Functions and transactions
List pgsql-admin
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

pgsql-admin by date:

Previous
From: Tsirkin Evgeny
Date:
Subject: Re: Functions and transactions
Next
From: "Subbiah, Stalin"
Date:
Subject: Schemas to Search_path