Re: replace " with nothing

From: Leif Biberg Kristensen <leif(at)solumslekt(dot)org>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: replace " with nothing
Date: 2011-05-11 21:11:07
Message-ID: 201105112311.08016.leif@solumslekt.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Ross J. Reedstrom 2011-05-11 21:22:32 Re: replace " with nothing
Previous Message Lew 2011-05-11 20:53:42 Re: replace " with nothing