Re: replace " with nothing - Mailing list pgsql-sql

From Leif Biberg Kristensen
Subject Re: replace " with nothing
Date
Msg-id 201105112311.08016.leif@solumslekt.org
Whole thread Raw
In response to replace " with nothing  (Tony Capobianco <tcapobianco@prospectiv.com>)
Responses Re: replace " with nothing  ("Ross J. Reedstrom" <reedstrm@rice.edu>)
List 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 by date:

Previous
From: Tony Capobianco
Date:
Subject: Re: replace " with nothing
Next
From: "Ross J. Reedstrom"
Date:
Subject: Re: replace " with nothing