From: | Arjen van der Meijden|Moderator P&W / Serverbeheer <acm(at)tweakers(dot)net> |
---|---|
To: | 'Stephane Schildknecht' <sschildknecht(at)aurora-linux(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Boolean to int |
Date: | 2002-07-05 15:12:17 |
Message-ID: | 000001c22436$5f87bb80$3ac15e91@acm |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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
But if that doesnt 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(at)aurora-linux(dot)com]
> Verzonden: vrijdag 5 juli 2002 15:39
> Aan: Arjen van der Meijden
> CC: pgsql-sql(at)postgresql(dot)org
> Onderwerp: Re: [SQL] Boolean to int
>
>
> Le jeu 04/07/2002 à 23:32, Arjen van der Meijden a écrit :
> > How about this hint in the postgresql-manual:
> >
> > "Tip: Values of the boolean type cannot be cast
> directly to other
> > types (e.g., CAST (boolval AS integer) does not work). This can be
> > accomplished using the CASE expression: CASE WHEN boolval
> THEN 'value if
> > true' ELSE 'value if false' END. See also Section 4.12. "
> >
> > For more information:
> > 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
> FROM document;
>
> And, that doesn't work either...
>
> psql:cnambo_proc_stock.sql:76: ERROR: select rule's target
> list has too many entries
>
>
> >
> --
> _Stéphane SCHILDKNECHT___________________________________
> | AurorA-SAS 69-71, Av. Pierre Grenier 92100 BOULOGNE |
> | Tel : 01.58.17.03.20 Fax : 01.58.17.03.21 |
> | mailto:sschildknecht(at)aurora-linux(dot)com - ICQ : 142504394 | "Free
> |Markets have taught that innovation is best when |
> | ideas flow freely." Adam Smith |
> |_________________________________________________________|
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Stephan Szabo | 2002-07-05 16:10:11 | Re: How do i return a dataset from a stored procedure |
Previous Message | Stephane Schildknecht | 2002-07-05 13:38:43 | Re: Boolean to int |