Thread: Accessing an array element from a function

Accessing an array element from a function

From
Mike Nolan
Date:
This may be mostly a documention issue:

I have a function with two parameters that returns an array: text[].

I want to access just the first element of that array within
my SQL statement.

This doesn't work:

    select myfunc(1,2)[1];

This does work:
    select (myfunc(1,2)[1];

If that's how it's supposed to work, is that documented somewhere?
--
Mike Nolan

Re: Accessing an array element from a function

From
Tom Lane
Date:
Mike Nolan <nolan@gw.tssi.com> writes:
> This doesn't work:
>     select myfunc(1,2)[1];

> This does work:
>     select (myfunc(1,2)[1];

I suppose you meant

     select (myfunc(1,2))[1];

> If that's how it's supposed to work, is that documented somewhere?

http://developer.postgresql.org/docs/postgres/sql-expressions.html#AEN1593

            regards, tom lane