Received: from gabuzo.meunet (IDENT:root@ppp-165-107.villette.club-internet.fr [195.36.165.107]) by hub.org (8.9.1/8.9.1) with ESMTP id HAA05574 for ; Fri, 15 Jan 1999 07:23:57 -0500 (EST) (envelope-from labouiss@club-internet.fr) Received: (from moi@localhost) by gabuzo.meunet (8.9.1a/8.9.1/Christophe Labouisse - 10/01/99) id NAA00820; Fri, 15 Jan 1999 13:10:59 +0100 To: pgsql-sql@postgreSQL.org Subject: Triggers, plpgsql, etc. Mime-Version: 1.0 (generated by tm-edit 7.108) Content-Type: multipart/mixed; boundary="Multipart_Fri_Jan_15_13:10:58_1999-1" Content-Transfer-Encoding: 7bit From: Christophe Labouisse Date: 15 Jan 1999 13:10:58 +0100 Message-ID: Lines: 54 X-Mailer: Gnus v5.5/XEmacs 20.4 - "Emerald" --Multipart_Fri_Jan_15_13:10:58_1999-1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit I want to have a « date of the last update » field in a table. So I create a table with datetime field (liens_maj) and a default value to 'now'. As shown below it works fine. lumiere=> insert into liens (liens_nom,liens_url) values ('Ga','GAbuzo'); INSERT 1009600 1 lumiere=> select * from liens; liens_id|liens_nom|liens_url|liens_commentaire|liens_maj --------+---------+---------+-----------------+---------------------------- 1|Ga |GAbuzo | |Thu Jan 14 13:29:35 1999 CET (1 row) To update automatically this field when the row is updated I thought of a trigger calling a plpgsql function : create trigger liens_maj_trig after update on liens for each row execute procedure liens_maj_fun(); create function liens_maj_fun () returns opaque as ' begin update liens set liens_maj=''now'' where liens_id=old.liens_id; return new; end; ' language 'plpgsql'; When I try to update a record I get the following error : lumiere=> update liens set liens_nom='zzz' where liens_id=1; ERROR: There is no operator '=$' for types 'int4' and 'int4' You will either have to retype this query using an explicit cast, or you will have to define the operator using CREATE OPERATOR Any idea ? --Multipart_Fri_Jan_15_13:10:58_1999-1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Christophe Labouisse : Cinéma, typographie, Unix labouiss@club-internet.fr http://gabuzo.home.ml.org/ Le cinéma en Lumière : http://www.lumiere.org/ --Multipart_Fri_Jan_15_13:10:58_1999-1--