> create function nac_viceversa() returns opaque as' > begin > NEW.minport := nacmin(OLD.sport,OLD.dport); > NEW.maxport := nacmax(OLD.sport,OLD.dport); > return NEW; > end; > 'language 'plpgsql'; > > create trigger nac_update after insert or update on traf > for each row execute procedure nac_viceversa(); > > but than > > ERROR: record old is unassigned yet > > if i take NEW. instead of OLD.: no errors -- but minport and maxport > are empty after insert. (could it be that OLD makes no sense on > insert? I'd lie if I'd say that I understood the conecpt, but > databases are hard stuff for me even in my native language) 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 NEW Data type RECORD; variable holding the new database row on INSERT/UPDATE operations on ROW level triggers. OLD Data type RECORD; variable holding the old database row on UPDATE/DELETE operations on ROW level triggers. Hope this helps, Joe ---------------------------(end of broadcast)--------------------------- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly