Re: simple update on boolean

From: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: simple update on boolean
Date: 2007-12-06 09:36:01
Message-ID: 20071206093601.GE2743@a-kretschmer.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

am Thu, dem 06.12.2007, um 10:25:26 +0100 mailte Cedric Boudin folgendes:
> Most honourable members of the list,
>
> this is a simple one, but I can't find the solution ( probably a
> forest/tree problem).
>
> update table set bolean_column = set_it_to_its_inverse where fk =
> some_value;

test=# create table forrest (id int, b bool);
CREATE TABLE
test=*# insert into forrest values (1,'f'::bool);
INSERT 0 1
test=*# insert into forrest values (2,'t'::bool);
INSERT 0 1
test=*# update forrest set b = case when b then 'f'::bool else 't'::bool end;
UPDATE 2
test=*# select * from forrest ;
id | b
----+---
1 | t
2 | f
(2 rows)

Okay?

Andreas
--
Andreas Kretschmer
Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Daniel Drotos 2007-12-06 09:47:12 Re: simple update on boolean
Previous Message Cedric Boudin 2007-12-06 09:25:26 simple update on boolean