pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Edmund Bacon <ebacon@onesystem.com>
To: pgsql-sql@postgresql.org
Subject: Conver bool to text
Date: Fri, 11 Mar 2005 09:57:37 -0700
Message-ID: <4231CE01.2090902@onesystem.com> (raw)

Is there a way to convert a boolean value to text and/or vice versa?

You can
  select 'true'::boolean,
which *seems* to convert a text string to boolean, but
  select 'true'::text::boolean
earns the message
  ERROR:  cannot cast type text to boolean

You can't go the other way either
 SELECT true::text
 ERROR:  cannot cast type boolean to text

and to_char() doesn't know about booleans.

It's not that difficult to write a fuction to convert boolean to text, 
but I'm wondering if there's already something that does this?

-- 
Edmund Bacon <ebacon@onesystem.com>




view thread (2+ messages)  latest in thread

Message-ID: <4231CE01.2090902@onesystem.com>
Permalink:  ../4231CE01.2090902@onesystem.com/
Also on:    postgresql.org/message-id/4231CE01.2090902@onesystem.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: ebacon@onesystem.com
  Subject: Re: Conver bool to text
  In-Reply-To: <4231CE01.2090902@onesystem.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