Search Postgresql Archives

Re: Copying data from int column to array column

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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/

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@xxxxxxxxxxxxxx

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux