Re: 7.2 search/replace pl/pgsql - Mailing list pgsql-novice

From Josh Berkus
Subject Re: 7.2 search/replace pl/pgsql
Date
Msg-id 200304060958.18328.josh@agliodbs.com
Whole thread Raw
In response to 7.2 search/replace pl/pgsql  (Nabil Sayegh <postgresql@e-trolley.de>)
Responses Re: 7.2 search/replace pl/pgsql
List 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


pgsql-novice by date:

Previous
From: Nabil Sayegh
Date:
Subject: 7.2 search/replace pl/pgsql
Next
From: Nabil Sayegh
Date:
Subject: Re: 7.2 search/replace pl/pgsql