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 [EMAIL PROTECTED]

Reply via email to