Re: Old values in statement triggers?

From: Brian Hirt <bhirt(at)me(dot)com>
To: Josh Kupershmidt <schmiddy(at)gmail(dot)com>
Cc: Grzegorz Jaśkiewicz <gryzman(at)gmail(dot)com>, Postgresql Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: Old values in statement triggers?
Date: 2010-10-21 14:32:35
Message-ID: 5F69DC17-7899-4E50-A7F9-5BA38B2CE2B2@me.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks Josh,

On Oct 21, 2010, at 7:49 AM, Josh Kupershmidt wrote:

> 2010/10/21 Grzegorz Jaśkiewicz <gryzman(at)gmail(dot)com>:
>> OLD.column_name
>> NEW.column_name ?
>
> I believe OP is asking specifically about statement-level triggers. As

Yup.

> the docs <http://www.postgresql.org/docs/current/static/trigger-definition.html>
> say:
> | Statement-level triggers do not currently have any way to
> | examine the individual row(s) modified by the statement.
>

I don't know how I didn't see that in the docs when I was looking. It must have been sleepy morning eyes or lack of coffee.

> What I've done is to have a row-level trigger that populates a
> temporary table with "interesting" changes that need further
> processing, and then a statement-level trigger which does bulk-updates
> based on what's in that temporary table. This comes in quite handy
> when bulk-loading data, e.g. with COPY.
>

I'll look at doing something like you describe, although I wonder if the overhead of doing a row trigger and then a mass update at the end with a statement trigger will really be worth it for what I'm doing. I might just end up doing only a row trigger.

--brian

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Aljoša Mohorović 2010-10-21 14:40:10 Re: postgres services on amazon
Previous Message Jos 2010-10-21 14:20:21 Re: postgres services on amazon