Just testing the regexp_string_to_array
This SQL
select description, regexp_string_to_array(description::text , E'\\s+' )
as optdesc, securitytype from xxxxxx where type = 'B' order by 1
produced this error:
ERROR: function regexp_string_to_array(text, text) does not exist
SQL state: 42883
Hint: No function matches the given name and argument types. You may
need to add explicit type casts.
Character: 21
Don't see the difference between the above and the example in the doc's.
kd
-----Original Message-----
From: Osvaldo Kussama [mailto:osvaldo.kussama@gmail.com]
Sent: Friday, September 05, 2008 4:47 PM
To: Kevin Duffy
Subject: Re: [SQL] variables with SELECT statement
2008/9/5, Kevin Duffy <KD@wrinvestments.com>:
> OK that is a syntax I have never seen. But correct we are getting
> close.
>
> Noticed that string_to_array does not handle double spaces very well.
> If there are double space between the tokens, there is "" (empty
string)
>
> in the array returned. Not exactly what I expected.
>
Try regexp_split_to_array().
http://www.postgresql.org/docs/current/interactive/functions-matching.ht
ml#FUNCTIONS-POSIX-REGEXP
SELECT regexp_split_to_array('the quick brown fox jumped over
the lazy dog', E'\\s+'); regexp_split_to_array
------------------------------------------------{the,quick,brown,fox,jumped,over,the,lazy,dog}
Osvaldo