pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feeddelete item[5] from varchar[] array???
7+ messages / 3 participants
[nested] [flat]
* delete item[5] from varchar[] array???
@ 2005-09-22 01:56 Matthew Peter <survivedsushi@yahoo.com>
2005-09-22 03:15 ` Re: delete item[5] from varchar[] array??? Michael Fuhr <mike@fuhr.org>
2005-09-22 03:17 ` Re: delete item[5] from varchar[] array??? Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 2 replies; 7+ messages in thread
From: Matthew Peter @ 2005-09-22 01:56 UTC (permalink / raw)
To: pgsql-sql
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]?
Could this be done in a SQL statement or a function? I
appreciate any help. Thank you
MP
______________________________________________________
Yahoo! for Good
Donate to the Hurricane Katrina relief effort.
http://store.yahoo.com/redcross-donate3/
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: delete item[5] from varchar[] array???
2005-09-22 01:56 delete item[5] from varchar[] array??? Matthew Peter <survivedsushi@yahoo.com>
@ 2005-09-22 03:15 ` Michael Fuhr <mike@fuhr.org>
2005-09-23 17:02 ` Re: delete item[5] from varchar[] array??? Matthew Peter <survivedsushi@yahoo.com>
1 sibling, 1 reply; 7+ messages in thread
From: Michael Fuhr @ 2005-09-22 03:15 UTC (permalink / raw)
To: Matthew Peter <survivedsushi@yahoo.com>; +Cc: 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
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: delete item[5] from varchar[] array???
2005-09-22 01:56 delete item[5] from varchar[] array??? Matthew Peter <survivedsushi@yahoo.com>
2005-09-22 03:15 ` Re: delete item[5] from varchar[] array??? Michael Fuhr <mike@fuhr.org>
@ 2005-09-23 17:02 ` Matthew Peter <survivedsushi@yahoo.com>
2005-09-23 19:10 ` Re: delete item[5] from varchar[] array??? Michael Fuhr <mike@fuhr.org>
0 siblings, 1 reply; 7+ messages in thread
From: Matthew Peter @ 2005-09-23 17:02 UTC (permalink / raw)
To: Michael Fuhr <mike@fuhr.org>; +Cc: pgsql-sql
--- Michael Fuhr <mike@fuhr.org> wrote:
> 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
>
I sure hope there is a better way :) There must be an
easy, native way to interface with arrays. We all know
programming languages have ways to delete items in an
array natively, it just needs to be exposed.
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: delete item[5] from varchar[] array???
2005-09-22 01:56 delete item[5] from varchar[] array??? Matthew Peter <survivedsushi@yahoo.com>
2005-09-22 03:15 ` Re: delete item[5] from varchar[] array??? Michael Fuhr <mike@fuhr.org>
2005-09-23 17:02 ` Re: delete item[5] from varchar[] array??? Matthew Peter <survivedsushi@yahoo.com>
@ 2005-09-23 19:10 ` Michael Fuhr <mike@fuhr.org>
2005-09-24 02:51 ` Re: delete item[5] from varchar[] array??? Matthew Peter <survivedsushi@yahoo.com>
0 siblings, 1 reply; 7+ messages in thread
From: Michael Fuhr @ 2005-09-23 19:10 UTC (permalink / raw)
To: Matthew Peter <survivedsushi@yahoo.com>; +Cc: pgsql-sql
On Fri, Sep 23, 2005 at 10:02:44AM -0700, Matthew Peter wrote:
> --- Michael Fuhr <mike@fuhr.org> wrote:
> > test=> UPDATE foo SET a = a[1:3] || a[5:6];
>
> I sure hope there is a better way :) There must be an
> easy, native way to interface with arrays.
Hoping a thing is true doesn't mean it must be true :-)
> We all know programming languages have ways to delete items in an
> array natively, it just needs to be exposed.
No, we don't all know that because it isn't generally true, or else
you're using a loose definition of "natively." Languages differ
in what capabilities they offer "natively."
contrib/intarray implements an intarray_del_elem() function,
presumably because the core product doesn't offer that capability,
or at least didn't when the module was written. If you think it's
there just waiting to be exposed, then dig into the source code and
expose it :-)
--
Michael Fuhr
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: delete item[5] from varchar[] array???
2005-09-22 01:56 delete item[5] from varchar[] array??? Matthew Peter <survivedsushi@yahoo.com>
2005-09-22 03:15 ` Re: delete item[5] from varchar[] array??? Michael Fuhr <mike@fuhr.org>
2005-09-23 17:02 ` Re: delete item[5] from varchar[] array??? Matthew Peter <survivedsushi@yahoo.com>
2005-09-23 19:10 ` Re: delete item[5] from varchar[] array??? Michael Fuhr <mike@fuhr.org>
@ 2005-09-24 02:51 ` Matthew Peter <survivedsushi@yahoo.com>
0 siblings, 0 replies; 7+ messages in thread
From: Matthew Peter @ 2005-09-24 02:51 UTC (permalink / raw)
To: Michael Fuhr <mike@fuhr.org>; +Cc: pgsql-sql
--- Michael Fuhr <mike@fuhr.org> wrote:
> On Fri, Sep 23, 2005 at 10:02:44AM -0700, Matthew
> Peter wrote:
> > --- Michael Fuhr <mike@fuhr.org> wrote:
> > > test=> UPDATE foo SET a = a[1:3] || a[5:6];
> >
> > I sure hope there is a better way :) There must be
> an
> > easy, native way to interface with arrays.
>
> Hoping a thing is true doesn't mean it must be true
> :-)
>
> > We all know programming languages have ways to
> delete items in an
> > array natively, it just needs to be exposed.
>
> No, we don't all know that because it isn't
> generally true, or else
> you're using a loose definition of "natively."
> Languages differ
> in what capabilities they offer "natively."
>
> contrib/intarray implements an intarray_del_elem()
> function,
> presumably because the core product doesn't offer
> that capability,
> or at least didn't when the module was written. If
> you think it's
> there just waiting to be exposed, then dig into the
> source code and
> expose it :-)
>
> --
> Michael Fuhr
>
Yes. I should've said "most" and some thanks to libs.
I'm busy in other source which is why I hoped those
who were already engulfed in pg's source would have a
solution... Thought this functionality may be
around... somewhere.... which is why I asked.
Took a brief look at intarray_del_elem() function you
mentioned. This may be perfect, and then some. I'll
play around with it. Thanks
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: delete item[5] from varchar[] array???
2005-09-22 01:56 delete item[5] from varchar[] array??? Matthew Peter <survivedsushi@yahoo.com>
@ 2005-09-22 03:17 ` Tom Lane <tgl@sss.pgh.pa.us>
2005-09-22 04:13 ` Re: delete item[5] from varchar[] array??? Matthew Peter <survivedsushi@yahoo.com>
1 sibling, 1 reply; 7+ messages in thread
From: Tom Lane @ 2005-09-22 03:17 UTC (permalink / raw)
To: Matthew Peter <survivedsushi@yahoo.com>; +Cc: pgsql-sql
Matthew Peter <survivedsushi@yahoo.com> writes:
> How is it possible to delete an item from a single
> dimension varchar[] array?
AFAIR there is no built-in function for this, but it seems like you
could write a generic polymorphic function for it easily enough.
regards, tom lane
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: delete item[5] from varchar[] array???
2005-09-22 01:56 delete item[5] from varchar[] array??? Matthew Peter <survivedsushi@yahoo.com>
2005-09-22 03:17 ` Re: delete item[5] from varchar[] array??? Tom Lane <tgl@sss.pgh.pa.us>
@ 2005-09-22 04:13 ` Matthew Peter <survivedsushi@yahoo.com>
0 siblings, 0 replies; 7+ messages in thread
From: Matthew Peter @ 2005-09-22 04:13 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-sql
Ya. I didn't see any in the \df. If it's so simple
could you show me one? PLEEEEEEEEEEEASE
Thanks
MP
--- Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Matthew Peter <survivedsushi@yahoo.com> writes:
> > How is it possible to delete an item from a single
> > dimension varchar[] array?
>
> AFAIR there is no built-in function for this, but it
> seems like you
> could write a generic polymorphic function for it
> easily enough.
>
> regards, tom lane
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2005-09-24 02:51 UTC | newest]
Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-09-22 01:56 delete item[5] from varchar[] array??? Matthew Peter <survivedsushi@yahoo.com>
2005-09-22 03:15 ` Michael Fuhr <mike@fuhr.org>
2005-09-23 17:02 ` Matthew Peter <survivedsushi@yahoo.com>
2005-09-23 19:10 ` Michael Fuhr <mike@fuhr.org>
2005-09-24 02:51 ` Matthew Peter <survivedsushi@yahoo.com>
2005-09-22 03:17 ` Tom Lane <tgl@sss.pgh.pa.us>
2005-09-22 04:13 ` Matthew Peter <survivedsushi@yahoo.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox