Re: delete item[5] from varchar[] array???

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Matthew Peter <survivedsushi(at)yahoo(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: delete item[5] from varchar[] array???
Date: 2005-09-22 03:15:12
Message-ID: 20050922031511.GB90260@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Wed, Sep 21, 2005 at 06:56:36PM -0700, Matthew Peter wrote:
> How is it possible to delete an item from a single
> dimension varchar[] array? Lets say it has the values
> {1,2,3,4,5,6}... how do i delete at position [4]?

I'm not sure if there's a better way, but you could concatenate the
slices adjacent to the position you want to delete:

test=> SELECT a FROM foo;
a
---------------
{1,2,3,4,5,6}
(1 row)

test=> UPDATE foo SET a = a[1:3] || a[5:6];
UPDATE 1
test=> SELECT a FROM foo;
a
-------------
{1,2,3,5,6}
(1 row)

--
Michael Fuhr

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2005-09-22 03:17:08 Re: delete item[5] from varchar[] array???
Previous Message Matthew Peter 2005-09-22 01:56:36 delete item[5] from varchar[] array???