Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 700594768EA for ; Fri, 5 Jul 2002 10:58:24 -0400 (EDT) Mailbox-Line: From sschildknecht@aurora-linux.com Fri Jul 5 10:58:24 2002 Received: from mailhost.aurora-linux.com (mailhost.aurora-linux.com [62.23.197.104]) by postgresql.org (Postfix) with ESMTP id B31BB476AE3 for ; Fri, 5 Jul 2002 09:38:24 -0400 (EDT) Received: from arrow.aurora-linux.com (ls.aurora-linux.com [62.23.197.102]) by mailhost.aurora-linux.com (Postfix) with ESMTP id 6AD3A91664; Fri, 5 Jul 2002 15:38:28 +0200 (CEST) Received: by arrow.aurora-linux.com (Postfix, from userid 1) id 08C4C3EE12; Fri, 5 Jul 2002 15:38:25 +0200 (CEST) Received: from fukse.aurora-linux.net (fukse.aurora-linux.net [192.168.10.121]) by arrow.aurora-linux.com (Postfix) with ESMTP id 7B7302F3A2; Fri, 5 Jul 2002 15:38:25 +0200 (CEST) Subject: Re: Boolean to int From: Stephane Schildknecht To: Arjen van der Meijden Cc: pgsql-sql@postgresql.org In-Reply-To: References: <1025803595.20819.239.camel@fukse> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable X-Mailer: Ximian Evolution 1.0.8 Date: 05 Jul 2002 15:38:43 +0200 Message-Id: <1025876323.10925.308.camel@fukse> Mime-Version: 1.0 X-AntiVirus: scanned for viruses by AMaViS 0.2.1 (http://amavis.org/) X-Spam-Status: No, hits=-4.0 required=5.0 tests=IN_REP_TO,DOUBLE_CAPSWORD,ASCII_FORM_ENTRY version=2.30 X-Spam-Level: X-Archive-Number: 200207/68 X-Sequence-Number: 8447 Le jeu 04/07/2002 =E0 23:32, Arjen van der Meijden a =E9crit : > How about this hint in the postgresql-manual: >=20 > "Tip: Values of the boolean type cannot be cast directly to other=20 > types (e.g., CAST (boolval AS integer) does not work). This can be=20 > accomplished using the CASE expression: CASE WHEN boolval THEN 'value if= =20 > true' ELSE 'value if false' END. See also Section 4.12. " >=20 > For more information:=20 > http://www.postgresql.org/idocs/index.php?datatype-boolean.html > and > http://www.postgresql.org/idocs/index.php?functions-conditional.html I tried that : CREATE RULE boolean_return AS ON SELECT TO DOCUMENT DO INSTEAD SELECT document_id, workflow_id, type_document_id, image_id, theme_id, document_version, document_surtitre, document_titre, document_chapeau, document_synthese, document_corps, document_pdf, document_date_creation, document_mot_clef, document_online, document_valid, CASE document_online WHEN TRUE THEN 1 WHEN FALSE THEN 0 END, CASE document_valid WHEN TRUE THEN 1 WHEN FALSE THEN 0 END=20 FROM document; And, that doesn't work either... psql:cnambo_proc_stock.sql:76: ERROR: select rule's target list has too many entries >=20 --=20 _St=E9phane SCHILDKNECHT___________________________________ | AurorA-SAS 69-71, Av. Pierre Grenier 92100 BOULOGNE | | Tel : 01.58.17.03.20 Fax : 01.58.17.03.21 |=20 | mailto:sschildknecht@aurora-linux.com - ICQ : 142504394 | | "Free Markets have taught that innovation is best when |=20 | ideas flow freely." Adam Smith | |_________________________________________________________|