X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 83FE49FB2CC for ; Fri, 4 Aug 2006 12:11:24 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 53436-01 for ; Fri, 4 Aug 2006 12:11:16 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.236]) by postgresql.org (Postfix) with ESMTP id 36CD69FB1E1 for ; Fri, 4 Aug 2006 12:11:16 -0300 (ADT) Received: by wx-out-0506.google.com with SMTP id t13so105291wxc for ; Fri, 04 Aug 2006 08:11:15 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=VcP5oknCweN7Oh1NQl7NCmtYudhnvcHZpgIk5KRAXtndUWpYYSFGSJClCX4viaFpExhBHsXGe+PnjZLFe8Di+EXnmbPDLEEuVI/hvlxTrkrRvmpHooXqCq+lbNhZ+3cJhj7jpXBMD1j3zNydV3oyvWRmFtHEZdpqm9BX+oyiHcI= Received: by 10.78.170.17 with SMTP id s17mr1450386hue; Fri, 04 Aug 2006 08:11:15 -0700 (PDT) Received: by 10.78.56.16 with HTTP; Fri, 4 Aug 2006 08:11:14 -0700 (PDT) Message-ID: <7c33d060608040811s6dcaa3abia137188076a76781@mail.gmail.com> Date: Fri, 4 Aug 2006 22:11:14 +0700 From: "David Garamond" To: pgsql-sql@postgresql.org Subject: Re: autoupdating mtime column In-Reply-To: <44D34242.6000901@archonet.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_31784_23473606.1154704274961" References: <7c33d060608040516n799af906sf74e1c645a47caff@mail.gmail.com> <44D34242.6000901@archonet.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.574 tagged_above=0 required=5 tests=DNS_FROM_RFC_ABUSE, HTML_30_40, HTML_MESSAGE, SPF_PASS X-Spam-Level: X-Archive-Number: 200608/35 X-Sequence-Number: 25993 ------=_Part_31784_23473606.1154704274961 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 8/4/06, Richard Huxton wrote: > > David Garamond wrote: > > Dear all, > > > > Please see SQL below. I'm already satisfied with everything except I > > wish in > > #4, mtime got automatically updated to NOW() if not explicitly SET in > > UPDATE > > statement. Is there a way to make the mtime column behave more like I > > wanted? Thanks in advance. > > Just check for OLD.mtime = NEW.mtime, or am I missing something here? > How do I differentiate between: UPDATE t SET mtime=mtime ...; in which mtime is specifically set and should not change, and UPDATE t SET foo=bar ...; in which mtime is not mentioned and should be updated automagically to NOW(). -- dave ------=_Part_31784_23473606.1154704274961 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On 8/4/06, Richard Huxton <dev@archonet.com> wrote:
David Garamond wrote:
> Dear all,
>
> Please see SQL below. I'm already satisfied with everything except I
> wish in
> #4, mtime got automatically updated to NOW() if not explicitly SET in
> UPDATE
> statement. Is there a way to make the mtime column behave more like I
> wanted? Thanks in advance.

Just check for OLD.mtime = NEW.mtime, or am I missing something here?

How do I differentiate between:

UPDATE t SET mtime=mtime ...;

in which mtime is specifically set and should not change, and

UPDATE t SET foo=bar ...;

in which mtime is not mentioned and should be updated automagically to NOW().

--
dave

------=_Part_31784_23473606.1154704274961--