Re: Appending to an array

From: Oleg Bartunov <oleg(at)sai(dot)msu(dot)su>
To: "Jay O'Connor" <joconnor(at)cybermesa(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Appending to an array
Date: 2003-04-15 14:48:40
Message-ID: Pine.GSO.4.53.0304151846500.25312@ra.sai.msu.su
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

If you work with array of integers you may try our contrib/intarray
module:

OPERATIONS:

int[] && int[] - overlap - returns TRUE if arrays has at least one common ele
ments.
int[] @ int[] - contains - returns TRUE if left array contains right array
int[] ~ int[] - contained - returns TRUE if left array is contained in right
array
# int[] - return the number of elements in array
int[] + int - push element to array ( add to end of array)
int[] + int[] - merge of arrays (right array added to the end of left one)
int[] - int - remove entries matched by right argument from array
int[] - int[] - remove right array from left
int[] | int - returns intarray - union of arguments
int[] | int[] - returns intarray as a union of two arrays
int[] & int[] - returns intersection of arrays
int[] @@ query_int - returns TRUE if array satisfies query (like '1&(2|3)')
query_int ~~ int[] - -/-

Oleg
On Tue, 15 Apr 2003, Jay O'Connor wrote:

> All,
>
> I've got a tablewhere one of the columns contains an array. What I'm
> trying to do is to append or insert into the array. I know I can so
> something like..
> UPDATE mytable set myarray[10] = 'some value' WHERE...
>
> ..to change a particular array element, and this be used to extend the
> array if the array is not that size yet, but what I need to figure out is
> how to do that when I don't know the size of the array at any given time.
>
> Thanks
>
> Jay
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
>

Regards,
Oleg
_____________________________________________________________
Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
Sternberg Astronomical Institute, Moscow University (Russia)
Internet: oleg(at)sai(dot)msu(dot)su, http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Corey W. Gibbs 2003-04-15 14:52:43 Re: [GENERAL] Are we losing momentum? Answer: Heck No!
Previous Message Bruce Momjian 2003-04-15 14:47:03 Re: Delete large amount of records and INSERT (with indexes)