pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: KÖPFERL Robert <robert.koepferl@sonorys.at>
Cc: Sql-Postgre <pgsql-sql@postgresql.org>
Subject: Converting varchar to bool
Date: Wed, 15 Jun 2005 14:14:46 +0200
Message-ID: <ED4E30DD9C43D5118DFB00508BBBA76EB1676C@neptun.sonorys.at> (raw)

Hi, 


I have currently trouble working with boolean values and variables in
functions.

As one would expect, a
select '1'::bool, 't'::bool, 'true'::unknown::boolean

works.

As a select '1' tells us this seems as a conversion unknown->bool
or ??maybe?? a boolean literal??

what-o-ever, at least my function gets not accepted:


CREATE OR REPLACE FUNCTION testbool(varchar)
  RETURNS boolean AS
$BODY$
SELECT $1::boolean
$BODY$
  LANGUAGE 'sql' STABLE STRICT SECURITY DEFINER;

Postgres complains that it can't convert varchar to boolean.
Actually neither  $1::unknown::bool works.
It turns out that there exists no conversion varchar/text/unknown ->
boolean.
Actually there's not any conversion  -> boolean.

How should this be treaten?
*being confused*


sorry for duplicating (I'm sure) this topic, at least I tried to find it in
the listarcive.



view thread (2+ messages)  latest in thread

Message-ID: <ED4E30DD9C43D5118DFB00508BBBA76EB1676C@neptun.sonorys.at>
Permalink:  ../ED4E30DD9C43D5118DFB00508BBBA76EB1676C@neptun.sonorys.at/
Also on:    postgresql.org/message-id/ED4E30DD9C43D5118DFB00508BBBA76EB1676C@neptun.sonorys.at

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: robert.koepferl@sonorys.at
  Subject: Re: Converting varchar to bool
  In-Reply-To: <ED4E30DD9C43D5118DFB00508BBBA76EB1676C@neptun.sonorys.at>
  References: <ED4E30DD9C43D5118DFB00508BBBA76EB1676C@neptun.sonorys.at>

* 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