Re: RE: search/replace in update

From: "Josh Berkus" <josh(at)agliodbs(dot)com>
To: Jeff Eckermann <jeckermann(at)verio(dot)net>, "'Josh Berkus'" <josh(at)agliodbs(dot)com>, Gary Stainburn <gary(dot)stainburn(at)ringways(dot)co(dot)uk>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: RE: search/replace in update
Date: 2001-06-14 16:38:28
Message-ID: web-71995@davinci.ethosmedia.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Jeff,

> Which function would you be suggesting? I hope not "translate".
> That works
> on characters, not strings. Easy to confuse if you don't read
> closely
> enough, as I found to my cost.

Hm? Darn! I'd swear there was a "replace" function in the various
string manipulation functions. My mistake.

> Easiest way using these functions would be:
> UPDATE table
> SET mobile_number = '07889' || substr (mobile_number, 5)
> WHERE mobile_number LIKE '0589%';
> Alternatively, you could define a generic search/replace function
> like:
> CREATE FUNCTION search_replace (text, text, text)
> RETURNS text AS '
> RETURN @_[0] =~ s/@_[1]/@_[2]/
> ' LANGUAGE 'plperl';

Hey, thanks! Do I have to "CREATE TRUSTED LANGUAGE" to enable plperl?

-Josh Berkus

______AGLIO DATABASE SOLUTIONS___________________________
Josh Berkus
Complete information technology josh(at)agliodbs(dot)com
and data management solutions (415) 565-7293
for law firms, small businesses fax 621-2533
and non-profit organizations. San Francisco

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2001-06-14 17:22:37 Re: Re: Timestamp without time zone
Previous Message Bruce Momjian 2001-06-14 16:35:31 Re: performance issues