Re: variables with SELECT statement - Mailing list pgsql-sql

From Kevin Duffy
Subject Re: variables with SELECT statement
Date
Msg-id DFC309C8A42633419600522FA8C4AE1A560F18@mail-01.wrcapital.corp
Whole thread Raw
In response to variables with SELECT statement  ("Kevin Duffy" <KD@wrinvestments.com>)
Responses Re: variables with SELECT statement  (Frank Bax <fbax@sympatico.ca>)
List pgsql-sql
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


pgsql-sql by date:

Previous
From: Frank Bax
Date:
Subject: Re: variables with SELECT statement
Next
From: Frank Bax
Date:
Subject: Re: variables with SELECT statement