Re: Valid Input Syntax for Type DATE

From: Andrew Gould <andrewlylegould(at)gmail(dot)com>
To: Andy Colson <andy(at)squeakycode(dot)net>
Cc: Rich Shepard <rshepard(at)appl-ecosys(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Valid Input Syntax for Type DATE
Date: 2012-02-29 18:42:41
Message-ID: CAFKhKgqSekO4j0hJephxORbcV6Ot=0XwtpP9GufiAvaxHOjcsg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Feb 29, 2012 at 12:29 PM, Andy Colson <andy(at)squeakycode(dot)net> wrote:
> On 2/29/2012 12:28 PM, Andy Colson wrote:
>>
>> On 2/29/2012 11:49 AM, Rich Shepard wrote:
>>>
>>> I'm trying to insert rows into a table, but some date and time columns
>>> are
>>> missing values. In the INSERT INTO ... statements of the .sql file I've
>>> tried various formats: ,, and ,'', and ,' ', but they all generate the
>>> error
>>> of invalid syntax for type date.
>>>
>>> When I have missing date of the date and time types, how do I validly
>>> represent them in the input file?
>>>
>>> Rich
>>>
>>>
>>>
>>
>> If the column is null'able, I think you can use the keyword: DEFAULT
>>
>> insert into(id, xdate) values (1, DEFAULT);
>>
>> Not 100%, but I think so.
>>
>> -Andy
>>
>
> Or... use NULL:
>
> insert into(id, xdate) values (1, NULL);
>
>
> -Andy

NULL works, but one advantage of using DEFAULT is that you won't have
to worry which columns are set to NOT NULL. This assumes that the NOT
NULL columns have default values assigned to them, which is a good
idea.

Andrew

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Vincent de Phily 2012-02-29 18:56:44 Privilege on schema 'public' not revokable
Previous Message Andy Colson 2012-02-29 18:29:52 Re: Valid Input Syntax for Type DATE