Re: 7.2 search/replace pl/pgsql

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: Nabil Sayegh <postgresql(at)e-trolley(dot)de>, pgsql-novice(at)postgresql(dot)org
Subject: Re: 7.2 search/replace pl/pgsql
Date: 2003-04-06 16:58:18
Message-ID: 200304060958.18328.josh@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Nabil,

> Has somebody a pl/pgsql function for search/replace by hand ?
> I heard that 7.3 can do this with plain sql, but unfortunately 7.3 is
> only available in unstable (debian) at the moment.
> So I have to stick to 7.2

I don't know about this ... search and replace is so easy in PL/perl, why
don't you use that?

CREATE FUNCTION strswap(
TEXT, VARCHAR, VARCHAR )
RETURNS TEXT AS '
my($the_text, $look_up, $replace_with) = @_;
$the_text =~ s:$look_up:$replace_with:eg ;
return $the_text;
' LANGUAGE 'plperl' WITH (ISCACHABLE, ISSTRICT);

--
-Josh Berkus
Aglio Database Solutions
San Francisco

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Josh Berkus 2003-04-06 18:15:44 Re: 7.2 search/replace pl/pgsql
Previous Message Nabil Sayegh 2003-04-06 15:41:24 7.2 search/replace pl/pgsql