Re: How to remove an item from integer array type

From: Alban Hertroys <haramrae(at)gmail(dot)com>
To: ChoonSoo Park <luispark(at)gmail(dot)com>
Cc: Ian Lawrence Barwick <barwick(at)gmail(dot)com>, PG-General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to remove an item from integer array type
Date: 2013-02-20 19:24:18
Message-ID: A7BF4F9C-FF1E-48BB-8421-7A3150EC4FD1@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Feb 20, 2013, at 17:51, ChoonSoo Park <luispark(at)gmail(dot)com> wrote:

> Sorry,
>
> 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:

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

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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Nathan Boley 2013-02-20 22:34:20 Foreign Exclusion Constraints
Previous Message Russell Keane 2013-02-20 17:47:01 Re: How to remove an item from integer array type