Re: How may I keep prepended array items positive?

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: How may I keep prepended array items positive?
Дата
Msg-id 20051101060340.GA5367@winnie.fuhr.org
обсуждение исходный текст
Ответ на How may I keep prepended array items positive?  (Matthew Peter <survivedsushi@yahoo.com>)
Ответы Re: How may I keep prepended array items positive?
Список pgsql-general
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

В списке pgsql-general по дате отправления:

Предыдущее
От: Erick Papadakis
Дата:
Сообщение: Cpanel and PostgreSQL 8.1rc
Следующее
От: Matthew Peter
Дата:
Сообщение: Re: How may I keep prepended array items positive?