Re: array_dims array_lower/upper distance

Поиск
Список
Период
Сортировка
От Matthew Peter
Тема Re: array_dims array_lower/upper distance
Дата
Msg-id 20050924030140.69487.qmail@web35214.mail.mud.yahoo.com
обсуждение исходный текст
Ответ на Re: array_dims array_lower/upper distance  (Guy Fraser <guy@incentre.net>)
Список pgsql-general
--- Guy Fraser <guy@incentre.net> wrote:

> On Fri, 2005-23-09 at 09:48 -0700, Matthew Peter
> wrote:
> >
> > --- Guy Fraser <guy@incentre.net> wrote:
> >
> ...snip...
> > > OK what I jotted down was totally wrong.
> > >
> > > This is slightly more correct :
> > >
> > > SELECT
> > >  array_upper(item,1) - array_lower(item,1) + 1
> as
> > > elements
> > > FROM
> > >  arraytest ;
> > >
> > > Without do a tonne of research, I can not refine
> > > this to handle
> > > all circumstances.
> > >
> > > Can someone point me to documentation that
> explains
> > > the function
> > > better than :
> > >
> > > Dimensions can also be retrieved with
> array_upper
> > > and array_lower, which
> > > return the upper and lower bound of a specified
> > > array dimension,
> > > respectively.
> > >
> > > The table "Table 9-36. array Functions" does not
> > > explain how empty
> > > and null arrays are handled either.
> > >
> > > How do array_upper() and array_lower() respond
> to :
> > > 1) NULL
> > > 2) Empty Array
> > > 3) Nonexistent requested dimension
> > >
> > > Also is there a function that specifies how many
> > > dimensions the
> > > array has?
> > >
> >
> > That was exactly the answer I was looking for when
> I
> > posted the question. Now if there was a function
> to
> > delete a position in the array....
> >
> > ie set array1 = array_delete_at(array1,5) where 5
> is
> > the position to delete
>
> I hope someone else can answer that, the best I can
> do
> is provide a link to the docs :
>
>
http://www.postgresql.org/docs/current/static/functions-array.html
>
> My best guess is that you need to "walk" the array
> and
> drop the element you don't want. The way I currently
>
> use arrays is I read the whole array into my
> application
> the modify the array then update the whole array.
>
> Unfortunately the arrays in PG are not associative
> and the
> elements must be sequential. I only use arrays in
> limited
> ways in PG because of earlier constraints, and have
> not
> needed to investigate the newer features.
>
> Good luck.
>

Ya. I read the docs and the (limitedly useful) Douglas
book. I'm just playing around with arrays. Michael
Fuhr suggested a intarray_del_elem() function. You may
want to take a look at it too?

MP

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Backend crash with user defined aggregate
Следующее
От: Michael Fuhr
Дата:
Сообщение: Re: question about to return two diferent tables from a function