From: | Matthew Peter <survivedsushi(at)yahoo(dot)com> |
---|---|
To: | Michael Fuhr <mike(at)fuhr(dot)org> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: How may I keep prepended array items positive? |
Date: | 2005-11-01 06:22:14 |
Message-ID: | 20051101062214.7391.qmail@web35211.mail.mud.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I want to use it like this...
UPDATE SET _array = {1,2,3} || _array;
Which if _array had {1} in it, I'd get something like
[-2:1]{1,1,2,3} as the range... I only want it to push
the existing values to the right so I'd have
[1:4]{1,1,2,3}
I don't have a pgsql on this box to show output..
--- Michael Fuhr <mike(at)fuhr(dot)org> wrote:
> On Mon, Oct 31, 2005 at 04:37:39PM -0800, Matthew
> Peter wrote:
> > I would need to prepend a couple array items BUT I
> > NEED them to be positive [1:13] instead of [-4:9]
> for
> > instance.
> >
> > How may I keep prepended array items positive?
>
> You could use array-to-array concatenation instead
> of prepending
> (aka element-to-array concatenation):
>
> test=> SELECT 99 || ARRAY[1, 2, 3]; -- unwanted
> results
> ?column?
> ------------------
> [0:3]={99,1,2,3}
> (1 row)
>
> test=> SELECT ARRAY[99] || ARRAY[1, 2, 3]; --
> desired results
> ?column?
> ------------
> {99,1,2,3}
> (1 row)
>
> --
> Michael Fuhr
>
__________________________________
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Fuhr | 2005-11-01 07:15:11 | Re: How may I keep prepended array items positive? |
Previous Message | Michael Fuhr | 2005-11-01 06:03:40 | Re: How may I keep prepended array items positive? |