Re: replace " with nothing

Поиск
Список
Период
Сортировка
От Leif Biberg Kristensen
Тема Re: replace " with nothing
Дата
Msg-id 201105112311.08016.leif@solumslekt.org
обсуждение исходный текст
Ответ на replace " with nothing  (Tony Capobianco <tcapobianco@prospectiv.com>)
Ответы Re: replace " with nothing  ("Ross J. Reedstrom" <reedstrm@rice.edu>)
Список pgsql-sql
On Wednesday 11 May 2011 22:29:40 Tony Capobianco wrote:
> We are converting from Oracle to Postgres.  An Oracle script contains
> this line:
>
>  select replace(firstname,'"'), memberid, emailaddress from members;
>
> in an effort to replace the " with nothing.  How can I achieve the same
> result with Postgres?
>
> Here's the Postgres error I get:
>
> select replace(firstname,'"'), memberid, emailaddress from members;
> ERROR:  function replace(character varying, unknown) does not exist
> LINE 1: select replace(firstname,'"'), memberid, emailaddress from m...

From the fine documentation
<http://www.postgresql.org/docs/current/static/functions-string.html>

replace(string text, from text, to text)

Example: replace('abcdefabcdef', 'cd', 'XX')

IOW, this function takes three parameters, the first one being the actual text
you want to make a replace on. Yor ecample above shoul probably be written as:

SELECT REPLACE((SELECT firstname FROM members), '%', ''), memberid,
emailaddress FROM members;

although it's a little above me why you would want to select firstname in the
first place when you proceed to replace it with nothing.

regards, Leif


В списке pgsql-sql по дате отправления:

Предыдущее
От: Tony Capobianco
Дата:
Сообщение: Re: replace " with nothing
Следующее
От: "Ross J. Reedstrom"
Дата:
Сообщение: Re: replace " with nothing