Joe Conway schrieb:
> OLD does not make sense on an insert because there is no "OLD" data for a
> brand new row. Similarly, there is no "NEW" data during a delete. See
> http://www.postgresql.org/idocs/index.php?plpgsql-trigger.html
Makes sense, thanks. And at the bottom of that page is a nice hint
regarding the trigger BEFORE/AFTER insert.
So I changed to BEFORE -- but still nothing happens
An exception for debugging:
create function nac_viceversa() returns opaque as'
declare
x int4;
begin
x := nacmin(NEW.sport,NEW.dport)
NEW.minport := x;
NEW.maxport := nacmax(NEW.sport,NEW.dport);
raise exception ''%'',x;
return NEW;
end;
'language 'plpgsql';
create trigger nac_update before insert or update on traf
for each row execute procedure nac_viceversa();
the calculation works...
ERROR: 110
ERROR: 110
ERROR: 110
... but is not written into the row -- even after removing the exception ;-)
id | ... | device | minport | maxport
12151 | ... | eth0 | |
12152 | ... | eth0 | |
Am I stupid?
Knut Sübert