Re: no value for numeric filed in SQL statement causes an error

Поиск
Список
Период
Сортировка
От Ian Harding
Тема Re: no value for numeric filed in SQL statement causes an error
Дата
Msg-id 3A7822BF.3E742BFB@pakrat.com
обсуждение исходный текст
Ответ на no value for numeric filed in SQL statement causes an error  (juerg.rietmann@pup.ch)
Список pgsql-sql
juerg.rietmann@pup.ch wrote:

> Hi there
>
> I have a table with char and int fields. From my form  I get no values back
> for int fields when they are left blank. This causes the SQL insert to
> fail.
>
> field     type
> name char
> id   int2
> city char
>
> insert into table (name,id,city) values ('roger rabbit',,'carrot city')
>
> The default for int/float fields is 0. Since I reuse the code of the
> referring page I don't like to have all fields assigned 0 at the beginning.
>
> Who can help ???
>
> Thanks ... jr
>
> ============================================
> PFISTER + PARTNER, SYSTEM - ENGINEERING AG
> Juerg Rietmann
> Grundstrasse 22a
> 6343 Rotkreuz
> Switzerland
>
> phone: +4141 790 4040
> fax: +4141 790 2545
> mobile: +4179 211 0315
> ============================================

That is by design, as they say.  You can allow the default to take effect by
changing your field list on the insert to not include id.

insert into table (name,city) values ('roger rabbit','carrot city')

I don't know what your front end is, but you could have it plug a figure into
the offending fields if blank as well.

Ian



В списке pgsql-sql по дате отправления:

Предыдущее
От: Karel Zak
Дата:
Сообщение: Re: Problem with Day of Week
Следующее
От: Ian Harding
Дата:
Сообщение: Re: Getting Results From Trigger