Subject Re: [firebird-support] toggle betweenn 0 and 1
Author Mark Rotteveel
On Wed, 2 Apr 2014 09:07:25 +0200, "checkmail" <check_mail@...>
wrote:
> is there a simple way to toggle between 0 and 1?
>
> Update table set column NOT column where id = :id?
>
> If column = 1 - then set to 0, else set to 1.

Sure:

COLUMN = 1 - COLUMN (however this assumes that the column is NOT NULL and
always 1 or 0).

or with a simple CASE:

COLUMN = CASE COLUMN WHEN 1 THEN 0 ELSE 1 END

or a searched CASE:

COLUMN = CASE WHEN COLUMN = 1 THEN 0 ELSE 1 END

Mark