Re: Possible to insert quoted null value into integer field?

Поиск
Список
Период
Сортировка
От gnari
Тема Re: Possible to insert quoted null value into integer field?
Дата
Msg-id 007901c48b46$9840c650$0100000a@wp2000
обсуждение исходный текст
Ответ на Possible to insert quoted null value into integer field?  (pablo_tweek@yahoo.com (Pablo S))
Ответы Re: Possible to insert quoted null value into integer field?  (Jan Wieck <JanWieck@Yahoo.com>)
Список pgsql-general
"Pablo S" <pablo_tweek@yahoo.com> wrote:


> Hi all, I have search high and low on this -
>
> Take for instance the statement :
>
> insert into foo (text1, text2, int1) values ('Foo', 'Bar', '');
>
> On Pg 7.2.x, the db would happily insert the null val into the int
> field.  HOWSOMEVER, 7.4.x will explode and error back with:
>
> "DBD::Pg::st execute failed: ERROR: invalid input syntax for integer:
> "" at /cgi-bin/foo line xxx"
>
> I see what it is complaining about but I am wondering if there is any
> way to roll back this feature, as I have this cheesy bit of perl that
> dynamically builds the query and quotes everything and I don't want to
> have to change all occurrences to insert the NULL or worse yet try to
> differentiate between int/string.

if all else fails, you might use a view mirroring the original
table, but with int1 defined as varchar, with rules handling the
conversion at insert/update.

gnari



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

Предыдущее
От: David Suela Fernández
Дата:
Сообщение: Re: copy a database
Следующее
От: Tino Wildenhain
Дата:
Сообщение: Re: Alter field type?