Re: 7.2 search/replace pl/pgsql
| От | Josh Berkus |
|---|---|
| Тема | Re: 7.2 search/replace pl/pgsql |
| Дата | |
| Msg-id | 200304060958.18328.josh@agliodbs.com обсуждение исходный текст |
| Ответ на | 7.2 search/replace pl/pgsql (Nabil Sayegh <postgresql@e-trolley.de>) |
| Ответы |
Re: 7.2 search/replace pl/pgsql
|
| Список | 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 по дате отправления: