Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f5EGcUE81545 for ; Thu, 14 Jun 2001 12:38:30 -0400 (EDT) (envelope-from josh@agliodbs.com) Received: from [209.10.40.250] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 3.4.1) with HTTP id 71995; Thu, 14 Jun 2001 09:38:28 -0700 From: "Josh Berkus" Subject: Re: RE: search/replace in update To: Jeff Eckermann , "'Josh Berkus'" , Gary Stainburn Cc: pgsql-sql@postgresql.org X-Mailer: CommuniGate Pro Web Mailer v.3.4.1 Date: Thu, 14 Jun 2001 09:38:28 -0700 Message-ID: In-Reply-To: <08CD1781F85AD4118E0800A0C9B8580B094AD7@NEZU> MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Archive-Number: 200106/213 X-Sequence-Number: 3471 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@agliodbs.com and data management solutions (415) 565-7293 for law firms, small businesses fax 621-2533 and non-profit organizations. San Francisco