Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 910CD476987 for ; Fri, 5 Jul 2002 12:41:00 -0400 (EDT) Mailbox-Line: From acm@tweakers.net Fri Jul 5 12:41:00 2002 Received: from ns1.tudelft.nl (ns1.tudelft.nl [130.161.180.1]) by postgresql.org (Postfix) with ESMTP id 2E43C476B1A for ; Fri, 5 Jul 2002 11:12:24 -0400 (EDT) Received: from CONVERSION-DAEMON.mailhost2.tudelft.nl by mailhost2.tudelft.nl (PMDF V6.0-025 #40925) id <0GYS003017KQPY@mailhost2.tudelft.nl> for pgsql-sql@postgresql.org; Fri, 05 Jul 2002 17:12:28 +0200 (MEST) Received: from listserv.tudelft.nl (listserv.tudelft.nl [130.161.180.33]) by mailhost2.tudelft.nl (PMDF V6.0-025 #40925) with ESMTP id <0GYS00MBN7KQYZ@mailhost2.tudelft.nl>; Fri, 05 Jul 2002 17:12:26 +0200 (MEST) Received: from acm (x193056-2.shuis-s.tudelft.nl [145.94.193.58]) by listserv.tudelft.nl (8.10.2+Sun/8.10.2) with ESMTP id g65FCQ322333; Fri, 05 Jul 2002 17:12:26 +0200 (MEST) Date: Fri, 05 Jul 2002 17:12:17 +0200 From: Arjen van der Meijden|Moderator P&W / Serverbeheer Subject: Re: Boolean to int In-reply-to: <1025876323.10925.308.camel@fukse> To: 'Stephane Schildknecht' Cc: pgsql-sql@postgresql.org Message-id: <000001c22436$5f87bb80$3ac15e91@acm> MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Mailer: Microsoft Outlook, Build 10.0.2627 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: QUOTED-PRINTABLE Importance: Normal X-Priority: 3 (Normal) X-MSMail-priority: Normal 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/90 X-Sequence-Number: 8469 Perhaps the 'create rule' is in the way, you could try something like: CASE WHEN document_online THEN 1 ELSE 0 END, CASE WHEN document_valid 1 ELSE 0 END=20 But if that doesn=92t work, I'm out of options aswel. You could try the "instead query" separately to test whether the query itself is correct. Goodluck > -----Oorspronkelijk bericht----- > Van: Stephane Schildknecht [mailto:sschildknecht@aurora-linux.com]=20 > Verzonden: vrijdag 5 juli 2002 15:39 > Aan: Arjen van der Meijden > CC: pgsql-sql@postgresql.org > Onderwerp: Re: [SQL] Boolean to int >=20 >=20 > 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=20 > directly to other > > types (e.g., CAST (boolval AS integer) does not work). This can be=20 > > accomplished using the CASE expression: CASE WHEN boolval=20 > THEN 'value if=20 > > true' ELSE 'value if false' END. See also Section 4.12. " > >=20 > > For more information: > > http://www.postgresql.org/idocs/index.php?datatype-boolean.html > > and > > http://www.postgresql.org/idocs/index.php?functions-conditional.html >=20 > I tried that : >=20 > 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; >=20 > And, that doesn't work either... >=20 > psql:cnambo_proc_stock.sql:76: ERROR: select rule's target=20 > list has too many entries >=20 >=20 > >=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=20 > |Markets have taught that innovation is best when | > | ideas flow freely." Adam Smith | > |_________________________________________________________| >=20 >=20