Re: ON UPDATE trigger question

From: Jorge Godoy <jgodoy(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: ON UPDATE trigger question
Date: 2007-09-12 22:52:51
Message-ID: 200709121952.51624.jgodoy@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wednesday 12 September 2007 15:56:13 Josh Trutwin wrote:
> If I create an ON UPDATE trigger run on each row after update, does
> the trigger fire only on rows affected by the update or for all rows?
>
> For example:
>
> CREATE TRIGGER my_update_trigger
> AFTER UPDATE ON my_table
> FOR EACH ROW
> EXECUTE PROCEDURE my_update_proc;
>
> UPDATE my_table SET my_val = my_val * 2;
>
> Will the trigger fire on rows that have NULL for my_val?

I haven't tested what you asked (you can do that easily), but if this is your
concern and if you have a huge table you might want to add a WHERE
clause: "WHERE my_val IS NOT NULL".

--
Jorge Godoy <jgodoy(at)gmail(dot)com>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jorge Godoy 2007-09-12 22:54:36 Re: Partial index with regexp not working
Previous Message Cultural Sublimation 2007-09-12 22:51:14 Re: Cannot declare record members NOT NULL