Обсуждение: Valid Input Syntax for Type DATE

Поиск
Список
Период
Сортировка

Valid Input Syntax for Type DATE

От
Rich Shepard
Дата:
   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



Re: Valid Input Syntax for Type DATE

От
Andy Colson
Дата:
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

Re: Valid Input Syntax for Type DATE

От
Andy Colson
Дата:
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

Re: Valid Input Syntax for Type DATE

От
Andrew Gould
Дата:
On Wed, Feb 29, 2012 at 12:29 PM, Andy Colson <andy@squeakycode.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

Re: Valid Input Syntax for Type DATE

От
Rich Shepard
Дата:
On Wed, 29 Feb 2012, Andrew Gould wrote:

>>> If the column is null'able, I think you can use the keyword: DEFAULT
>>> insert into(id, xdate) values (1, DEFAULT);

>> Or... use NULL:
>> insert into(id, xdate) values (1, NULL);

> 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.

   Thank you both.

Rich