PL/pgSQL

From: Michael Fork <mfork(at)toledolink(dot)com>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: PL/pgSQL
Date: 2000-04-05 23:58:11
Message-ID: Pine.BSI.4.21.0004051953250.13461-100000@glass.toledolink.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

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

Browse pgsql-interfaces by date

  From Date Subject
Next Message Joseph Shraibman 2000-04-06 01:12:05 Re: Debian + PG + JDBC
Previous Message Nikolai Turchanikov 2000-04-05 23:34:26 JDBC: Method setBinaryStream Question