Received: from internet.coordinadora.com.co (coordinadora.com.co [206.114.28.138]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f11LjCq91485 for ; Thu, 1 Feb 2001 16:45:14 -0500 (EST) (envelope-from ramiroa@coordinadora.com.co) Received: from jrarenas ([192.168.2.120]) by internet.coordinadora.com.co (8.9.3/8.8.7) with SMTP id QAA01247 for ; Thu, 1 Feb 2001 16:45:04 -0500 From: =?iso-8859-1?Q?Ramiro_Arenas_Ram=EDrez?= To: Subject: how to create this trigger? Date: Thu, 1 Feb 2001 16:48:28 -0500 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) X-MimeOLE: Produced By Microsoft MimeOLE V5.00.3018.1300 Importance: Normal X-Archive-Number: 200102/4 X-Sequence-Number: 1172 I need to create a trigger that increment a value in a column of table1 where a row is inserted in table 2 I have tried whit this but it just does nothing. CREATE FUNCTION increment_value () RETURNS opaque AS 'DECLARE code int4; BEGIN code := new.code; UPDATE table1 SET value = value + 1 WHERE id = code; RETURN NEW; END;' LANGUAGE 'plpgsql'; CREATE TRIGGER insert_on_table2 BEFORE INSERT ON table2 FOR EACH ROW EXECUTE PROCEDURE increment_value(); Can you help me?