Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 0C34A1337C50 for ; Wed, 11 May 2011 18:11:52 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 34957-03-6 for ; Wed, 11 May 2011 21:11:44 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail44.e.nsc.no (mail44.e.nsc.no [193.213.115.44]) by mail.postgresql.org (Postfix) with ESMTP id D975E1337C0A for ; Wed, 11 May 2011 18:11:10 -0300 (ADT) Received: from balapapa.localnet (168.173.16.62.customer.cdi.no [62.16.173.168]) (authenticated bits=0) by mail44.nsc.no (8.14.4/8.14.4) with ESMTP id p4BLB8Gx005587 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Wed, 11 May 2011 23:11:09 +0200 (MEST) From: Leif Biberg Kristensen To: pgsql-sql@postgresql.org Subject: Re: replace " with nothing Date: Wed, 11 May 2011 23:11:07 +0200 User-Agent: KMail/1.13.7 (Linux/2.6.38-gentoo-r4; KDE/4.6.2; x86_64; ; ) References: <1305145780.1954.4.camel@tony1.localdomain> In-Reply-To: <1305145780.1954.4.camel@tony1.localdomain> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <201105112311.08016.leif@solumslekt.org> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201105/78 X-Sequence-Number: 35362 On Wednesday 11 May 2011 22:29:40 Tony Capobianco wrote: > We are converting from Oracle to Postgres. An Oracle script contains > this line: >=20 > select replace(firstname,'"'), memberid, emailaddress from members; >=20 > in an effort to replace the " with nothing. How can I achieve the same > result with Postgres? >=20 > Here's the Postgres error I get: >=20 > 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... =46rom the fine documentation=20 replace(string text, from text, to text) Example: replace('abcdefabcdef', 'cd', 'XX') IOW, this function takes three parameters, the first one being the actual t= ext=20 you want to make a replace on. Yor ecample above shoul probably be written = as: SELECT REPLACE((SELECT firstname FROM members), '%', ''), memberid,=20 emailaddress FROM members; although it's a little above me why you would want to select firstname in t= he=20 first place when you proceed to replace it with nothing. regards, Leif