Hi Newsgroup!

I can't believe I have found a good solution here. I want to return the 
last value of an array with an SQL statement, while I do not know, how many 
items the array holds (u can never be sure of that since u can redim an 
array in PostgreSQL whenever u like..).

That is what i came up with:


select my_array_field[substr(array_dims(my_array_field), 4, 1)]
from my_table;


But this only works, as long as the upper boundary is from 1 to 9 (one 
digit). Besides it looks ugly and will perform likewise.

Did I miss something here?
Is there any function returning more sensible data than array_dims 
(returning something like '[1:4]')?

Grateful for any hints.
Regards
Erwin Brandstetter

-- 
no z in my mail.

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
      joining column's datatypes do not match

Reply via email to