Subject | Update more than one column in only one row with a trigger: |
---|---|
Author | fridge_n |
Post date | 2009-08-01T20:00:01Z |
Probably it is a newbie question but after hours of surfing and trying I hope somebody can help me.
I want to update two columns in one row out of a different table with a before update trigger.
What I can create is an update of one column in one row.
Beneath is what I have used:
Could anybody help.
Thanks in advance,
fridge_n
I want to update two columns in one row out of a different table with a before update trigger.
What I can create is an update of one column in one row.
Beneath is what I have used:
>asI would expect that the next sample would work, but it doesn't.
>begin
>if (old.field_a is null and new.field_a>0) then
> update table_2
>set new.field_b = (select field_2 from table_1
>where field_1 = new.field_a);
>end
>asI can't compile it, the error start at the â(â after set. I really haven't got a clue.
>begin
>if (old.field_a is null and new.field_a>0) then
>update table_2
>set (new.field_b, new.field_c) = (select field_2, field_3 from table_1
>where field_1 = new.field_a);
>end
Could anybody help.
Thanks in advance,
fridge_n