Re: How to remove an item from integer array type - Mailing list pgsql-general

From Alban Hertroys
Subject Re: How to remove an item from integer array type
Date
Msg-id A7BF4F9C-FF1E-48BB-8421-7A3150EC4FD1@gmail.com
Whole thread Raw
In response to Re: How to remove an item from integer array type  (ChoonSoo Park <luispark@gmail.com>)
List pgsql-general
On Feb 20, 2013, at 17:51, ChoonSoo Park <luispark@gmail.com> wrote:

> Sorry,
>=20
> It's not ordered by value. It's not sorted list unfortunately. It can =
be '{100, 120, 102, 130, 104}'.

Are you saying it's an unordered list for which the order matters? That =
seems a bit peculiar.

What would probably work is to split the array around the value to =
remove, and merge those arrays again.
Something like this:

=3D> select (ARRAY[100, 101, 102, 103, 104])[1:2] || (ARRAY[100, 101, =
102, 103, 104])[4:5];
 ?column?
 -------------------
 {100,101,103,104}
 (1 row)=20
    =20

Alban Hertroys
--
If you can't see the forest for the trees,
cut the trees and you'll find there is no forest.

pgsql-general by date:

Previous
From: Russell Keane
Date:
Subject: Re: How to remove an item from integer array type
Next
From: Nathan Boley
Date:
Subject: Foreign Exclusion Constraints