Re: How can I insert NULL into column with the type of timestamp?

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: bookman bookman <bookmanb(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How can I insert NULL into column with the type of timestamp?
Date: 2007-12-12 15:44:45
Message-ID: 20071212154445.GE7925@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

bookman bookman escribió:

> Then error occured:
> error:invalid input syntax for type timestamp:""
> context:copy T_Admin ,line 2,column regDate:""
> It seemed that the column REGDATE cannot accept a NULL.I tested it use:
> insert into T_Admin(name,key,regDate,isLock,realName)
> values('aaa','aaa','','1','aaa');
> The same error occured.
>
> So it means that the column with type timestamp cannot accept a NULL
> .Is there any way I can tansfer this table into postgre?How can i deal
> with NULL in this case?

No, it doesn't mean that. It means that you are trying to insert an
empty string. Try this:

insert into T_Admin(name,key,regDate,isLock,realName)
values('aaa','aaa',NULL,'1','aaa');

Similarly, the NULL timestamp column in the file you give to COPY should
not contain empty quotes.

--
Alvaro Herrera http://www.advogato.org/person/alvherre
"Crear es tan difícil como ser libre" (Elsa Triolet)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Collin Kidder 2007-12-12 15:46:50 Re: Would it be OK if I put db file on a ext2 filesystem?
Previous Message SHARMILA JOTHIRAJAH 2007-12-12 15:41:37 slony1 replication question