Re: [HACKERS] current_time?

From: Vince Vielhaber <vev(at)michvhf(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] current_time?
Date: 1999-10-20 10:47:36
Message-ID: Pine.BSF.4.05.9910200643370.3080-100000@paprika.michvhf.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 20 Oct 1999, Tom Lane wrote:

> Vince Vielhaber <vev(at)michvhf(dot)com> writes:
> > Now I thought this was discussed recently and this:
> > create table foo(
> > x int,
> > y datetime default current_time);
> > would put the current date and time into y whenever a new record was
> > inserted. It appears to give the date and time the stupid table was
> > created. Is it me or is something broke?
>
> The behavior for this was changed very recently. Since current sources
> refuse the above:
>
> regression=> create table foo(
> regression-> x int,
> regression-> y datetime default current_time);
> ERROR: Attribute 'y' is of type 'datetime' but default expression is of type 'time'
> You will need to rewrite or cast the expression
>
> I am guessing you are trying it with 6.5.*, where indeed you will likely
> get the time of table creation. Recommended approach is
> y datetime default now()
> which works the way you want in all Postgres versions AFAIK.

This works. I had tried something earlier (during the thread a couple
weeks back) DEFAULT TEXT 'now' which didn't work at all for me. A
little playing and I just now figured out why it didn't work.. When I
tried that I had y as a text field - which only put a 'now' in it so I
was avoiding using now under the assumption that it wouldn't work.

Vince.
--
==========================================================================
Vince Vielhaber -- KA8CSH email: vev(at)michvhf(dot)com flame-mail: /dev/null
# include <std/disclaimers.h> Have you seen http://www.pop4.net?
Online Campground Directory http://www.camping-usa.com
Online Giftshop Superstore http://www.cloudninegifts.com
==========================================================================

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Vince Vielhaber 1999-10-20 10:55:32 Re: [HACKERS] book status
Previous Message Peter Eisentraut 1999-10-20 10:26:30 Re: [HACKERS] Readline use in trouble?