Displaying 1 result from an estimated 1 matches for "merge_quota2".
Did you mean:
merge_quota
2011 Dec 15
1
Quota PostgreSQL INSERT trigger
...ing INSERT on the table from within BEFORE INSERT trigger creates
cascading trigger.
http://www.postgresql.org/docs/current/interactive/trigger-definition.html
Instead, one should return NEW record from the trigger, and it will be
inserted after trigger execution.
---
CREATE OR REPLACE FUNCTION merge_quota2() RETURNS TRIGGER AS $$
BEGIN
IF NEW.messages < 0 OR NEW.messages IS NULL THEN
-- ugly kludge: we came here from this function, really do try to insert
IF NEW.messages IS NULL THEN
NEW.messages = 0;
ELSE
NEW.messages = -NEW.messages;
END IF;
return NEW;
END IF...