Re: case statement within insert

From: Francisco Olarte <folarte(at)peoplecall(dot)com>
To: tango ward <tangoward15(at)gmail(dot)com>
Cc: "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: case statement within insert
Date: 2018-05-25 15:41:50
Message-ID: CA+bJJbyi-EXJaZDJNKs49nfEFFGp+ZWyEiW+vFYKaC7szQ_7Sg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, May 25, 2018 at 11:04 AM, tango ward <tangoward15(at)gmail(dot)com> wrote:
> CASE
> WHEN code like '%%PE%%' or code like '%%NSTP%%'
> THEN True
> ELSE False

I cannot advise you on the %% stuff, which I do not totally understand, but

CASE WHEN condition THEN true ELSE false END

when contition is ( as it should in a CASE ) a boolean expression is a
classic antipattern , just use 'condition' or '(condition)'

Francisco Olarte.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Erlend Sogge Heggen 2018-05-25 20:03:27 Syndicating PostgreSQL mailing list to Discourse
Previous Message Adrian Klaver 2018-05-25 14:19:55 Re: case statement within insert