Skip site navigation (1) Skip section navigation (2)

Re: variables with SELECT statement

From: "Kevin Duffy" <KD(at)wrinvestments(dot)com>
To: <pgsql-sql(at)postgresql(dot)org>
Cc: "Osvaldo Kussama" <osvaldo(dot)kussama(at)gmail(dot)com>
Subject: Re: variables with SELECT statement
Date: 2008-09-05 21:03:54
Message-ID: DFC309C8A42633419600522FA8C4AE1A560F18@mail-01.wrcapital.corp (view raw or flat)
Thread:
Lists: 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(dot)kussama(at)gmail(dot)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(at)wrinvestments(dot)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

Responses

pgsql-sql by date

Next:From: Frank BaxDate: 2008-09-05 21:13:06
Subject: Re: variables with SELECT statement
Previous:From: Frank BaxDate: 2008-09-05 20:44:20
Subject: Re: variables with SELECT statement

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group