From: | Christoph Haller <ch(at)rodos(dot)fzk(dot)de> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Cc: | Andreas(dot)Pflug(at)web(dot)de |
Subject: | Re: How to notice column changes in trigger |
Date: | 2003-03-07 12:04:54 |
Message-ID: | 3E688AE5.5714092D@rodos.fzk.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
>
> How can I detect whether a column was changed by an update command
> inside a trigger?
>
> create table test(a int, b int, c int, primary key(a))
>
> b and c should be updated inside an update trigger if not modified by
> the statement itself
>
> 1) update test set a=0 -> trigger does its work
> 2) update test set a=0, b=1, c=2 -> trigger does nothing
> 3) update test set a=0, b=b, c=c -> trigger does nothing, but content
of
> a and b dont change either although touched
>
> What I'm looking for is something like
> IF NOT COLUMN_TOUCHED(b) THEN ...
> For MSSQL, this would be coded as IF NOT UPDATE(b) ..
>
> IF OLD.b=NEW.b will not work, case 3) will falsely execute the trigger
code.
>
Sorry, but I don't get it.
Does
> b and c should be updated inside an update trigger if not modified by
> the statement itself
mean b=b not modified, b=1 modified even if b was 1 before ?
So you want the trigger executed only if assignments to b and/or c do
not appear within the update command. Right?
Regards, Christoph
From | Date | Subject | |
---|---|---|---|
Next Message | Andre Schubert | 2003-03-07 12:47:02 | Re: Help on indexing timestamps |
Previous Message | Andre Schubert | 2003-03-07 12:02:23 | Re: Help on indexing timestamps |