Re: [SQL] DEFAULT TEXT 'now' - Mailing list pgsql-sql

From Ross J. Reedstrom
Subject Re: [SQL] DEFAULT TEXT 'now'
Date
Msg-id 36F9124F.E2460C2C@rice.edu
Whole thread Raw
In response to DEFAULT TEXT 'now'  (Roberto Joao Lopes Garcia <roberto@mha.com.br>)
List pgsql-sql
Anatoly K. Lasareff wrote:
>
> >>>>> "RJLG" == Roberto Joao Lopes Garcia <roberto@mha.com.br> writes:
>
>> <snipped problem with using default 'now'>

> <snipped description of using now() instead>

What version of postgresql are you all using? I tried RJLG's example
code with 6.4.2, and it worked - I got different times at each insert,
so the default 'now' was being calculated at insertion time, not table
creation time. Here's what it looks like:

test2=> \d conex

Table    = conex
+----------------------------------+----------------------------------+-------+
|              Field               |              Type                |
Length|
+----------------------------------+----------------------------------+-------+
| id                               | int4 not null default nextval (
|     4 |
| inicio                           | datetime default text 'now'
|     8 |
| ultimo                           | datetime default text 'now'
|     8 |
| ip                               | inet
|   var |
+----------------------------------+----------------------------------+-------+
Index:    conex_pkey
test2=> select * from conex;
id|inicio                      |ultimo
|             ip
--+----------------------------+----------------------------+---------------
 1|Tue Mar 23 13:40:24 1999 CST|Tue Mar 23 13:40:24 1999
CST|200.200.200.200
 2|Tue Mar 23 13:40:28 1999 CST|Tue Mar 23 13:40:28 1999
CST|200.200.200.202
 3|Tue Mar 23 13:40:30 1999 CST|Tue Mar 23 13:40:30 1999
CST|200.200.200.203
 4|Tue Mar 23 13:41:06 1999 CST|Tue Mar 23 13:41:06 1999
CST|200.200.200.203
 5|Tue Mar 23 13:41:21 1999 CST|Tue Mar 23 13:41:21 1999
CST|200.200.200.205
(5 rows)

test2=>

???

Ross

--
Ross J. Reedstrom, Ph.D., <reedstrm@rice.edu>
NSBRI Research Scientist/Programmer
Computer and Information Technology Institute
Rice University, 6100 S. Main St.,  Houston, TX 77005

pgsql-sql by date:

Previous
From: Herouth Maoz
Date:
Subject: Re: [SQL] transaction-lock?
Next
From: Jenny DiBartolomeo
Date:
Subject: Comparing Dates to Current Time