Accessing an array element from a function

Started by Mike Nolanover 21 years ago2 messagesgeneral
Jump to latest
#1Mike Nolan
nolan@gw.tssi.com

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

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Mike Nolan (#1)
Re: Accessing an array element from a function

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