Thread: INSERT and UPDATE with non-atomic values

INSERT and UPDATE with non-atomic values

From
Martin Jackson
Date:
Hello all,

I am using PostgreSQL in large part because it supports arrays as
attributes.  I have spent the better part of the last couple days trying
to figure out how one would UPDATE dynamically sized arrays.  Also, is
there an easy way of getting the size of a dynamic array?

Thanks in advance.

-- 
Martin Jackson: mjackson@deskmedia.com
++++++++++++++++++++++++++++++++++++++
Computer Info. Science Major
Minnesota State University, Mankato
++++++++++++++++++++++++++++++++++++++


Re: [SQL] INSERT and UPDATE with non-atomic values

From
Chris Bitmead
Date:
create table foo (bar int4[]);
insert into foo values('{1,2,3}');
update foo set bar[2] = 4;
update foo set bar = '{5,4,4,4,5}';

I don't think you can extend a dynamic array without setting the entire
array (like the last example), which is probably a bit unfortunate.

If you're using arrays you may want to check out the stuff in
pgsql/contrib/array as well.

Martin Jackson wrote:
> 
> Hello all,
> 
> I am using PostgreSQL in large part because it supports arrays as
> attributes.  I have spent the better part of the last couple days trying
> to figure out how one would UPDATE dynamically sized arrays.  Also, is
> there an easy way of getting the size of a dynamic array?
> 
> Thanks in advance.
> 
> --
> Martin Jackson: mjackson@deskmedia.com
> ++++++++++++++++++++++++++++++++++++++
> Computer Info. Science Major
> Minnesota State University, Mankato
> ++++++++++++++++++++++++++++++++++++++

-- 
Chris Bitmead
http://www.bigfoot.com/~chris.bitmead
mailto:chris.bitmead@bigfoot.com