X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A0E3052823 for ; Wed, 15 Jun 2005 09:15:11 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 77574-10 for ; Wed, 15 Jun 2005 12:15:10 +0000 (GMT) Received: from mx-00.sil.at (mx-00.sil.at [62.116.68.196]) by svr1.postgresql.org (Postfix) with ESMTP id 8492052812 for ; Wed, 15 Jun 2005 09:15:05 -0300 (ADT) Received: (qmail-ldap/ctrl 45813 invoked from network); 15 Jun 2005 12:14:58 -0000 Received: from unknown (HELO io.sonorys.at) ([213.235.243.42]) (envelope-sender ) by mx-00.sil.at (qmail-ldap-1.03) with SMTP for ; 15 Jun 2005 12:14:58 -0000 Received: from neptun.sonorys.at (neptun.sonorys.at [172.24.1.17]) by io.sonorys.at (8.11.7+Sun/8.11.7) with ESMTP id j5FCEkG17173 for ; Wed, 15 Jun 2005 14:14:46 +0200 (MEST) Received: by neptun.sonorys.at with Internet Mail Service (5.5.2653.19) id ; Wed, 15 Jun 2005 14:14:46 +0200 Message-ID: From: =?ISO-8859-1?Q?K=D6PFERL_Robert?= To: Cc: Sql-Postgre Subject: Converting varchar to bool Date: Wed, 15 Jun 2005 14:14:46 +0200 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="ISO-8859-1" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.01 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200506/167 X-Sequence-Number: 21768 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.