i've got a "_rating" table that, when a new record is added,
i'd like to have propagate through some other tables to update
running totals:
CREATE FUNCTION _rating_propagate( _rating ) RETURNS OPAQUE AS '
DECLARE
n ALIAS FOR $1;
opinion char(1) := upper(substring(n.rating from 1 for 1));
BEGIN
UPDATE sometable SET fld = fld + 1 WHERE id = .... ;
UPDATE othertable SET fld = fld + 1 WHERE id = .... ;
[yada yada]
END;
' LANGUAGE 'plpgsql';
CREATE TRIGGER _rating_propagate
BEFORE INSERT ON _rating
FOR EACH ROW EXECUTE PROCEDURE _rating_propagate( NEW );
INSERT INTO _rating VALUES ( ... );
the insert into _rating works fine, but none of the other tables
are actually UPDATED. who's got the clue stick?
--
will@serensoft.com
http://www.dontUthink.com/