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

From tolik@icomm.ru (Anatoly K. Lasareff)
Subject Re: [SQL] DEFAULT TEXT 'now'
Date
Msg-id 87ogljz7kd.fsf@tolikus.hq.aaanet.ru
Whole thread Raw
In response to DEFAULT TEXT 'now'  (Roberto Joao Lopes Garcia <roberto@mha.com.br>)
List pgsql-sql
>>>>> "RJLG" == Roberto Joao Lopes Garcia <roberto@mha.com.br> writes:

 RJLG> Hi
 RJLG> I╢m have a table like bellow:

 RJLG> CREATE TABLE conex (
 RJLG> id int4 PRIMARY KEY DEFAULT NEXTVAL('seq_conex'),

 RJLG> inicio datetime DEFAULT TEXT 'now',
 RJLG> ultimo datetime DEFAULT TEXT
 RJLG> 'now',
 RJLG> .
 RJLG> .
 RJLG> .
 RJLG> )

 RJLG> insert into conex (ip) values(╢200.200.200.200╢)

 RJLG> Will result every time the same data and time for ╢inicio╢ and ╢ultimo╢!

You must type


inicio datetime DEFAULT TEXT now(),
                             ^^^^^

This is the function which calls every time you insert new record. In
your case 'now' is the constant, which calculates once, when you
create the table.

--
Anatoly K. Lasareff              Email:       tolik@icomm.ru
Senior programmer

pgsql-sql by date:

Previous
From: Howie
Date:
Subject: Re: [SQL] DEFAULT TEXT 'now'
Next
From: Herouth Maoz
Date:
Subject: Re: [SQL] transaction-lock?