X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 0B31CD1D08C for ; Thu, 15 Apr 2004 08:15:28 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 69968-10 for ; Thu, 15 Apr 2004 08:15:29 -0300 (ADT) Received: from anchor-post-30.mail.demon.net (anchor-post-30.mail.demon.net [194.217.242.88]) by svr1.postgresql.org (Postfix) with ESMTP id 2E924D1C9C8 for ; Thu, 15 Apr 2004 08:15:23 -0300 (ADT) Received: from tmsl-adsl.demon.co.uk ([80.177.114.181] helo=bacon.tmsl.demon.co.uk) by anchor-post-30.mail.demon.net with esmtp (Exim 3.35 #1) id 1BE4q5-000Acu-0U; Thu, 15 Apr 2004 12:15:25 +0100 Date: Thu, 15 Apr 2004 12:15:23 +0100 From: Paul Thomas To: Dan Field Cc: "pgsql-sql @ postgresql . org" Subject: Re: problem porting MySQL SQL to Postgres Message-ID: <20040415121523.A864@bacon> References: <4A063822-8EC7-11D8-9677-000A958E367A@llgc.org.uk> Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset=ISO-8859-1 In-Reply-To: <4A063822-8EC7-11D8-9677-000A958E367A@llgc.org.uk>; from dof@llgc.org.uk on Thu, Apr 15, 2004 at 11:25:59 +0100 X-Mailer: Balsa 1.2.3 Lines: 54 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200404/136 X-Sequence-Number: 17511 On 15/04/2004 11:25 Dan Field wrote: > I've stumbled across a query I don't quite understand the error message > for. > > This query is pulled from a working MySQL setup: > > SELECT > DEWEY_ID, DEWEY_HUNDREDS, DEWEY_TENS, DEWEY_ONES, > DEWEY_POINT_ONES, DEWEY_POINT_TENS, DEWEY_POINT_HUNDREDS, > DEWEY_POINT_THOUSANDS, DEWEY_TYPE, DEWEY_LANG, DEWEY_SUBJECT > FROM lu_dewey > WHERE > (DEWEY_HUNDREDS = 9) AND > (DEWEY_TENS >= 0) AND (DEWEY_TENS <= 9) AND > (DEWEY_ONES = 0 || DEWEY_ONES = NULL) AND > (DEWEY_POINT_ONES = 0 || DEWEY_POINT_ONES = NULL) AND > (DEWEY_POINT_TENS = 0 || DEWEY_POINT_TENS = NULL) AND > (DEWEY_POINT_HUNDREDS = 0 || DEWEY_POINT_HUNDREDS = NULL) AND > (DEWEY_POINT_THOUSANDS = 0 || DEWEY_POINT_THOUSANDS = NULL) AND > (DEWEY_TYPE = 't') AND > (DEWEY_LANG = 'en') > ORDER BY DEWEY_TENS > > > However I'm getting the following error: > > ERROR: Unable to identify an operator '=' for types 'character' and > 'boolean' You will have to retype this query using an explicit cast. > > > Any help would be much appreciated You're trying to use the string concatenation operator (||) in a boolean test.. That's an invalid comparison according to the SQL specs. You need to use the SQL OR operator e.e., (DEWEY_POINT_TENS = 0 OR DEWEY_POINT_TENS = NULL) AND ~~ Your "= NULL" tests are also not valid SQL (should be IS NULL). MySQL does not follow the specs in a number or areas. PostgreSQL is very standards-complient. Write valid SQL and you should be OK. HTH -- Paul Thomas +------------------------------+---------------------------------------------+ | Thomas Micro Systems Limited | Software Solutions for Business | | Computer Consultants | http://www.thomas-micro-systems-ltd.co.uk | +------------------------------+---------------------------------------------+