Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 153C52E0040 for ; Mon, 25 Feb 2008 21:21:25 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 11222-05 for ; Mon, 25 Feb 2008 21:21:22 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from ag-out-0708.google.com (ag-out-0708.google.com [72.14.246.248]) by postgresql.org (Postfix) with ESMTP id 501502E0039 for ; Mon, 25 Feb 2008 21:21:22 -0400 (AST) Received: by ag-out-0708.google.com with SMTP id 5so5350466agb.7 for ; Mon, 25 Feb 2008 17:21:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:references:x-google-sender-auth; bh=Ltrahpo9fuxPGu/9uqKyPue7F5YmUH+5HN7GcA89BG4=; b=Gvcl6M54gb9fvXJgyrSs+Zm4TzjwuCH/zJ8WrxqOpJ97wsICSGvCfTrXa/fM1n4lvueQfyV/um/ocPlzJQM9n7QtW9maXCtpI1d4GTdLg0uMJbafLzuDhAY1+2tlLafdIWfOBW7/cur+Pie+0b2coL16mjWg/oVgHydkFCaDBzU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:references:x-google-sender-auth; b=C/GTWK6cDyYHIKMe+8se/9P0SGLf72nPfjxgj8GchZ34At20n66WcyWG/fQf8U5CZkMPDlxV+G8LZxEeVCjAFwCsF0fMh/DpQA6jF5K2jq8tgouhPxKCss2LiwQEtHK6gdYAM3SDoeZSGWwMzsrQV8KWiVzdSlFL8T6+quqaT1U= Received: by 10.70.21.4 with SMTP id 4mr2620037wxu.22.1203988881112; Mon, 25 Feb 2008 17:21:21 -0800 (PST) Received: by 10.70.89.12 with HTTP; Mon, 25 Feb 2008 17:21:21 -0800 (PST) Message-ID: Date: Mon, 25 Feb 2008 19:21:21 -0600 From: "Aaron Bono" To: "David Bear" Subject: Re: example of insert timestamp Cc: pgsql-admin@postgresql.org In-Reply-To: <200802251821.19453.david.bear@asu.edu> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_3429_24598798.1203988881103" References: <200802251821.19453.david.bear@asu.edu> X-Google-Sender-Auth: a1a889335b0d6c18 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200802/331 X-Sequence-Number: 28405 ------=_Part_3429_24598798.1203988881103 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On Mon, Feb 25, 2008 at 7:21 PM, David Bear wrote: > I've been reading about triggers on insert and found the page at > http://www.postgresql.org/docs/8.1/interactive/triggers.html with some > sample > code in the comments. > > I'm thinking what I want can't really be this involved. > > I want to have a table with a timestamp field that automatically gets the > value of now() on insert. The timestamp will never be updated. I assume I > need to create a trigger to do this. If there is an easier way, please > advise. > > Otherwise, is there any sample code that would should be how to do this? > The > sample on the page above looks like overkill. > In your create table statement: "create_dt" TIMESTAMP WITHOUT TIME ZONE DEFAULT now() NOT NULL -- ================================================================== Aaron Bono Aranya Software Technologies, Inc. http://www.aranya.com http://codeelixir.com ================================================================== ------=_Part_3429_24598798.1203988881103 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On Mon, Feb 25, 2008 at 7:21 PM, David Bear <david.bear@asu.edu> wrote:
I've been reading about triggers on insert and found the page at
http://www.postgresql.org/docs/8.1/interactive/triggers.html with some sample
code in the comments.

I'm thinking what I want can't really be this involved.

I want to have a table with a timestamp field that automatically gets the
value of now() on insert. The timestamp will never be updated. I assume I
need to create a trigger to do this. If there is an easier way, please
advise.

Otherwise, is there any sample code that would should be how to do this? The
sample on the page above looks like overkill.

In your create table statement:

"create_dt" TIMESTAMP WITHOUT TIME ZONE DEFAULT now() NOT NULL

--
==================================================================
  Aaron Bono
  Aranya Software Technologies, Inc.
  http://www.aranya.com
  http://codeelixir.com
================================================================== ------=_Part_3429_24598798.1203988881103--