Quote:
|
Originally Posted by afiaccone
Postgres v 8.1.23
|
Wow, what an ancient beast. You should upgrade to a supported version as soon as possible (ideally 9.x)
Quote:
|
Originally Posted by afiaccone
UPDATE JOB_STATUS set DURATION=new_duration where CLIENT_ID=cid and JOB_ID=jid and DATE_ID=dateID; RETURN NULL; END;
|
You do not run UPDATEs in a trigger, simply assign the value to the new record.
So your function becomes this:
Code:
CREATE FUNCTION duration_recalc() RETURNS TRIGGER AS $$
BEGIN
IF (NEW.JOB_END != OLD.JOB_END) THEN
new.duration := (NEW.JOB_END - OLD.JOB_START)/60000;
END IF;
RETURN new;
END; $$
LANGUAGE plpgsql;
You can also see this in the example in the manual:
PostgreSQL: Documentation: Manuals: PostgreSQL 8.1: Trigger Procedures
And please use [code] tags in the future to format your SQL code so it's better readable.
For details see here: http://www.dbforums.com/misc.php?do=bbcode