Re: 'true'::TEXT::BOOLEAN

From: Achilleus Mantzios <achill(at)matrix(dot)gatewaynet(dot)com>
To: Markus Bertheau ☭ <twanger(at)bluetwanger(dot)de>
Cc: "'PostgreSQL'" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: 'true'::TEXT::BOOLEAN
Date: 2005-06-03 11:45:39
Message-ID: Pine.LNX.4.44.0506031442080.23350-100000@matrix.gatewaynet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

O Markus Bertheau β^Ψ­ έγραψε στις Jun 3, 2005 :

> Π’ ΠŸΡ‚Π½, 03/06/2005 Π² 14:20 +0300, Achilleus Mantzios ΠΏΠΈΡˆΠ΅Ρ‚:
> > O Markus Bertheau Ξ²^Ψ­ έγραψΡ στις Jun 3, 2005 :
> >
> > > Hi,
> > >
> > > What's the type I need to convert text to before I can convert it to
> > > boolean?
> >
> > just 't' will suffice.
>
> Well, that's not my question. I have a plpgsql function like that:
>
> CREATE FUNCTION object_new(class TEXT, properties TEXT[])
>
> which I call like
>
> object_new('Car', ARRAY['color', 'red', 'new', 'true'])
>
> That means set color to red and new to true. In the function I need to
> call
>
> object_set_boolean_property(object_id INT, property_name TEXT,
> property_value BOOLEAN)
>
> And I can't call it with a TEXT variable, because casting from TEXT to
> BOOLEAN isn't possible.

Then use the
case when ... then ... when ... then ... else ... end
construct, e.g.
case when mytext='true' then 't'::boolean else 'f'::boolean end

Hmm, why dont you leave it as 'true' or 'false' without any castings.

>
> Markus
>

--
-Achilleus

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Markus Bertheau ☭ 2005-06-03 11:52:35 Re: 'true'::TEXT::BOOLEAN
Previous Message Achilleus Mantzios 2005-06-03 11:20:44 Re: 'true'::TEXT::BOOLEAN