X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E3EA553BDC for ; Thu, 21 Apr 2005 22:58:54 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 52955-04 for ; Fri, 22 Apr 2005 01:58:51 +0000 (GMT) Received: from metux.de (seven.metux.de [193.16.1.1]) by svr1.postgresql.org (Postfix) with ESMTP id 61CAF53BA3 for ; Thu, 21 Apr 2005 22:58:49 -0300 (ADT) Received: (from weigelt@localhost) by metux.de (8.12.10/8.12.10) id j3M1wqci004198 for pgsql-sql@postgresql.org; Fri, 22 Apr 2005 03:58:52 +0200 Date: Fri, 22 Apr 2005 03:58:52 +0200 From: Enrico Weigelt To: pgsql-sql Subject: RULE for mtime recording Message-ID: <20050422015852.GA1298@nibiru.borg.metux.de> Reply-To: weigelt@metux.de Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.1i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200504/315 X-Sequence-Number: 21208 Hi folks, I'd like to write an update rule, which touches the a mtime field (=current_timestamp) on normal update - when the mtime field isnt explicitly set. If the update query explictly sets an mtime value, this value has to be let through. my tables look like: -- base class CREATE TABLE inode ( inode_id oid not null default nextval('inode_id_seq'), mtime timestamp not null default current_timestamp ); -- example class CREATE TABLE foo ( bar text ) INHERITS ( inode ); now if I do UPDATE foo SET bar = 'xyz' WHERE ... the mtime should be set to the current time, but on UPDATE foo SET bar = '123', mtime = '2001-09-11' WHERE ... we shall have 9/11 as mtime. Is this possible with rules ? thx -- --------------------------------------------------------------------- Enrico Weigelt == metux IT service phone: +49 36207 519931 www: http://www.metux.de/ fax: +49 36207 519932 email: contact@metux.de cellphone: +49 174 7066481 --------------------------------------------------------------------- -- DSL ab 0 Euro. -- statische IP -- UUCP -- Hosting -- Webshops -- ---------------------------------------------------------------------