pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Achilleus Mantzios <achill@matrix.gatewaynet.com>
To: Markus Bertheau ☭ <twanger@bluetwanger.de>
Cc: 'PostgreSQL' <pgsql-sql@postgresql.org>
Subject: Re: 'true'::TEXT::BOOLEAN
Date: Fri, 3 Jun 2005 14:45:39 +0300 (EEST)
Message-ID: <Pine.LNX.4.44.0506031442080.23350-100000@matrix.gatewaynet.com> (raw)
In-Reply-To: <1117799555.9816.24.camel@dicaprio.akademie1.de>

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




view thread (15+ messages)  latest in thread

Message-ID: <Pine.LNX.4.44.0506031442080.23350-100000@matrix.gatewaynet.com>
Permalink:  ../Pine.LNX.4.44.0506031442080.23350-100000@matrix.gatewaynet.com/
Also on:    postgresql.org/message-id/Pine.LNX.4.44.0506031442080.23350-100000@matrix.gatewaynet.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: achill@matrix.gatewaynet.com, twanger@bluetwanger.de
  Subject: Re: 'true'::TEXT::BOOLEAN
  In-Reply-To: <Pine.LNX.4.44.0506031442080.23350-100000@matrix.gatewaynet.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox