Re: element from an array by its index - Mailing list pgsql-general

From Sam Mason
Subject Re: element from an array by its index
Date
Msg-id 20090721144730.GO5407@samason.me.uk
Whole thread Raw
In response to element from an array by its index  (Murat Kabilov <kabilovmf@gmail.com>)
Responses Re: element from an array by its index
List pgsql-general
On Tue, Jul 21, 2009 at 04:08:51PM +0600, Murat Kabilov wrote:
> I would like to know if there is a function that extracts an element by its
> index from an array?

No, the syntax most people expect and use would be arr[ndx].  If you
want a function, it would be easy to do:

  CREATE FUNCTION array_index(anyarray,int)
      RETURNS anyelement IMMUTABLE
      LANGUAGE sql AS $$
    SELECT $1[$2]; $$;

--
  Sam  http://samason.me.uk/

pgsql-general by date:

Previous
From: Craig Ringer
Date:
Subject: Re: ***UNCHECKED*** Re: memory leak occur when disconnect database
Next
From: Tom Lane
Date:
Subject: Re: ***UNCHECKED*** Re: memory leak occur when disconnect database