From: | Antonio Silva <aolinto(dot)lst(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Rob Sargent <robjsargent(at)gmail(dot)com>, "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>, osvaldo(dot)kussama(at)gmail(dot)com |
Subject: | Re: using replace function |
Date: | 2019-12-02 16:26:26 |
Message-ID: | CAE8g1gPEJNjM7p_xCx7avLK7eou0TsFf-2VN3qaHXd7+PxeURg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi Osvaldo, Rod, David and Tom
Thanks for your attention. Lastly it is not that difficult.
For me the more natural way is Rod's suggestion, to use replace with where.
I don't know why I didn't think of this solution.
The usage of regexp_replace is very nice too and I will take a time to
learn it.
Thanks a lot to you all
Antonio
Em sex., 29 de nov. de 2019 às 01:22, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> escreveu:
> "David G. Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> writes:
> > On Thursday, November 28, 2019, Rob Sargent <robjsargent(at)gmail(dot)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
>
--
Antônio Olinto Ávila da Silva
Biólogo / Oceanógrafo
Instituto de Pesca (Fisheries Institute)
São Paulo, Brasil
From | Date | Subject | |
---|---|---|---|
Next Message | stan | 2019-12-02 17:10:32 | Preformance on upcoming Linux kernel |
Previous Message | Steve Atkins | 2019-12-02 16:01:28 | Re: slow insert speeds with bytea |