Re: Copying data from int column to array column

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: Copying data from int column to array column
Дата
Msg-id 20050608131911.GA71371@winnie.fuhr.org
обсуждение исходный текст
Ответ на Copying data from int column to array column  (Adam Witney <awitney@sgul.ac.uk>)
Список pgsql-general
On Wed, Jun 08, 2005 at 01:21:19PM +0100, Adam Witney wrote:
>
> UPDATE test SET field3[1] = field1;
>
> Why does the UPDATE of field2 work, but the UPDATE of field3 does not?

What version of PostgreSQL are you using?  The example should work
in 8.x.  See the Release Notes:

http://www.postgresql.org/docs/8.0/static/release-8-0.html

"Updating an element or slice of a NULL array value now produces a
non-NULL array result, namely an array containing just the assigned-to
positions."

In previous versions you can get around the problem by first setting
the column to an empty array:

UPDATE test SET field3 = '{}' WHERE field3 IS NULL;
UPDATE test SET field3[1] = field1;

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

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

Предыдущее
От: Együd Csaba
Дата:
Сообщение: Re: Where to find translation of Postgres error messages?
Следующее
От: Richard_D_Levine@raytheon.com
Дата:
Сообщение: Re: To SPAM or not to SPAM...