Re: using replace function

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: using replace function
Дата
Msg-id 18661.1575001344@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: using replace function  ("David G. Johnston" <david.g.johnston@gmail.com>)
Ответы Re: using replace function
Список pgsql-general
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Thursday, November 28, 2019, Rob Sargent <robjsargent@gmail.com> wrote:
>> I want to replace a string (not a substring) in a field but making sure
>> that the string in the full field.

> I’d probably do something like:
> Select case when a.col = ‘value’ then ‘new value’ else a.col end from a;

Yeah, this.  You could wrap it up in a SQL function if you want the
same level of notational convenience as replace().

Another possibility is regexp_replace with an anchored pattern, but
that would potentially require escaping regexp metacharacters in the
pattern, so the PITA factor is high.  And I doubt it'd be faster than
the CASE solution.

            regards, tom lane



В списке pgsql-general по дате отправления:

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: using replace function
Следующее
От: Nandakumar M
Дата:
Сообщение: Re: Rows violating Foreign key constraint exists