Re: Appending to an array - Mailing list pgsql-general

From Oleg Bartunov
Subject Re: Appending to an array
Date
Msg-id Pine.GSO.4.53.0304151846500.25312@ra.sai.msu.su
Whole thread Raw
In response to Appending to an array  ("Jay O'Connor" <joconnor@cybermesa.com>)
List 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@sai.msu.su, http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83


pgsql-general by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Delete large amount of records and INSERT (with indexes)
Next
From: "Corey W. Gibbs"
Date:
Subject: Re: Are we losing momentum? Answer: Heck No!