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

From ChoonSoo Park
Subject How to remove an item from integer array type
Date
Msg-id CACgbiFuFnJ+6wO45JLv76jXyaBXCfbn3gx6F4GO7HLh0dV=_Nw@mail.gmail.com
Whole thread Raw
Responses Re: How to remove an item from integer array type  (Ian Lawrence Barwick <barwick@gmail.com>)
List pgsql-general
Hello Gurus,

Table A has integer[] column. I need to delete specific integer value from
that column.

f1     |     f2
1           {100, 101, 102, 103}
2           {200, 300, 400}

I want to remove 101 from f2 and also preserve the order.

f1     |     f2
1           {100, 102, 103}
2           {200, 300, 400}

I tried the following query and it did remove the 101 but it didn't
preserve the order.
update tableA set f2 = (select array_agg(X.id) from (select unnest(f2) id
except select 101 id) X) where f1 = 1;

What's the best way to do this?

Thank you,
Choon Park

pgsql-general by date:

Previous
From: Vincent Veyron
Date:
Subject: Re: Perl function leading to out of memory error
Next
From: Ian Lawrence Barwick
Date:
Subject: Re: How to remove an item from integer array type