Re: function DECODE and triggers - Mailing list pgsql-general

From Oliver Elphick
Subject Re: function DECODE and triggers
Date
Msg-id 1130322130.32260.2.camel@braydb.bray-healthcare.com
Whole thread Raw
In response to Re: function DECODE and triggers  ("Rafael Montoya" <rafo-mm@hotmail.com>)
List pgsql-general
On Tue, 2005-10-25 at 18:31 +0200, Rafael Montoya wrote:
> Thanks for your answer, and if i have many options like
>
> decode (pre.C_EST,'01','U','02','M','03','W','04','D','05','O','06','S','')
> as Est
>
> do i have to write many else options in this way?
>
> select case when pre.C_EST = '01' THEN 'U'
>          ELSE when pre-C_EST = '02' THEN 'M'
>            ...
>          END AS EST
>
> Rafael

The syntax is

  CASE WHEN condition1 THEN value1
       WHEN condition2 THEN value2
       ...
       ELSE default_value
  END

Oliver


pgsql-general by date:

Previous
From: "Andrus"
Date:
Subject: Re: alt+F not working after calling pg_dump
Next
From: Alban Hertroys
Date:
Subject: Re: function DECODE and triggers