Monotone-Revision: 9054022ef1ca8aeba6e34842d27d9b94ce002b89 Monotone-Author: dev-unix.inverse.qc.ca Monotone-Date: 2006-06-15T19:34:10 Monotone-Branch: ca.inverse.sogo
18 lines
456 B
Plaintext
18 lines
456 B
Plaintext
CREATE FUNCTION mise_a_jour_t2() RETURNS trigger AS '
|
|
BEGIN
|
|
IF TG_OP = 'INSERT' OR TG_OP = 'UPDATE' THEN
|
|
UPDATE table2 SET champ2 = champ2 + 1 WHERE... ;
|
|
RETURN NEW;
|
|
ELSE IF TG_OP = 'DELETE'
|
|
UPDATE table2 SET champ2 = champ2 - 1 WHERE ... ;
|
|
RETURN OLD ;
|
|
END IF;
|
|
END;
|
|
|
|
' LANGUAGE plpgsql;
|
|
|
|
CREATE TRIGGER mise_a_jour
|
|
AFTER INSERT OR UPDATE OR DELETE
|
|
ON table1
|
|
FOR EACH ROW EXECUTE PROCEDURE mise_a_jour_t2();
|