How to put into 'now' into a datetime field

From: Martin Neumann <mne(at)mne(dot)de>
To: pgsql-sql(at)postgreSQL(dot)org
Subject: How to put into 'now' into a datetime field
Date: 1999-09-07 06:22:22
Message-ID: m11OEe6-000DJ3C@darwin.oche.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

table foobar {
[...]
created datetime NOT NULL DEFAULT x
}

I want to put the current transaction time into
"created" when inserting into the table. After reading the manual
I've tried the following combinations for x:

'now'
''now''
(''now'')
('now')
datetime('now')
datetime(''now'')
datetime('now'::abstime)
'now'::datetime
('now'::datetime)

And perhaps some more I forgot. The only one not resulting in an
syntax error when creating the table is 'now'. But using simply 'now'
gives a strange result:

When I insert the first tuple the datetime-value is okay.
But when I insert further tuples they get the same datetime-value
as the first inserted tuple.

--
Martin Neumann
mne(at)mne(dot)de

Browse pgsql-sql by date

  From Date Subject
Next Message leonardo albrizio 1999-09-07 20:26:47 (no subject)
Previous Message Dipankar Chakrabarti 1999-09-07 04:37:44 Re:Stored Procs