After creating the following trigger and function, no more records
are added to the datbase, with no visible errors, exceptions, etc. Does
anyone see my mistake? Thanks in advance.
CREATE FUNCTION ti_acct_update() RETURNS OPAQUE AS 'DECLARE time int4; BEGIN IF
NEW.acctstatustype= ''STOP'' THEN SELECT ti_time INTO prev_time FROM tiacct WHERE ((NEW.username
=ti_username) AND (datepart(''month'', NEW.tstamp) == ti_month) AND
(datepart(''year'',NEW.tstamp)== ti_year)); IF NOT FOUND THEN INSERT INTO tiacct (ti_username,
ti_month,ti_year, ti_time) VALUES (NEW.username, datepart(''month'', NEW.tstamp),
datepart(''year'',NEW.tstamp),NEW.acctsessiontime); ELSE time := prev_time +
NEW.acctsessiontime; UPDATE tiacct (ti_time) VALUES (time) WHERE ((NEW.username = ti_username) AND
(datepart(''month'', NEW.tstamp) == ti_month) AND (datepart(''year'',NEW.tstamp) ==
ti_year)); END IF; END IF; RETURN NEW; END; ' LANGUAGE 'plpgsql';
CREATE TRIGGER ti_acct_update AFTER INSERT ON radacct
FOR EACH ROW EXECUTE PROCEDURE ti_acct_update();
Michael Fork - CCNA - MCP - A+
Network Support - Toledo Internet Access - Toledo Ohio