Search Postgresql Archives

question about array indexing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hey,
I'm wondering if this isn't a bug somewhere in the parser. I had to add additional parenthesis around the regexp_split_to_array.


$ with x as (select 'a b c' a)
select
    regexp_split_to_array(a, ' ')
from x;

 regexp_split_to_array
-----------------------
 {a,b,c}
(1 row)

$ with x as (select 'a b c' a)
select
    regexp_split_to_array(a, ' ')[1]
from x;

ERROR:  syntax error at or near "["
LINE 3:     regexp_split_to_array(a, ' ')[1]
                                                             ^
$ with x as (select 'a b c' a)
select
    (regexp_split_to_array(a, ' '))[1]
from x;
 regexp_split_to_array
-----------------------
 a
(1 row)



regards,
Szymon

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux