From: Leif Biberg Kristensen <leif@solumslekt.org>
To: pgsql-sql@postgresql.org
Subject: Re: replace " with nothing
Date: Wed, 11 May 2011 23:11:07 +0200
Message-ID: <201105112311.08016.leif@solumslekt.org> (raw)
In-Reply-To: <1305145780.1954.4.camel@tony1.localdomain>
References: <1305145780.1954.4.camel@tony1.localdomain>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: leif@solumslekt.org
Subject: Re: replace " with nothing
In-Reply-To: <201105112311.08016.leif@solumslekt.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox