Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 428B76322B2 for ; Tue, 7 Jul 2009 06:17:53 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 39680-04 for ; Tue, 7 Jul 2009 06:17:36 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from outmail137146.authsmtp.com (outmail137146.authsmtp.com [62.13.137.146]) by mail.postgresql.org (Postfix) with ESMTP id 5C122632CD3 for ; Tue, 7 Jul 2009 06:17:41 -0300 (ADT) Received: from mail-c193.authsmtp.com (mail-c193.authsmtp.com [62.13.128.118]) by punt9.authsmtp.com (8.14.2/8.14.2/Kp) with ESMTP id n679HVrS007622; Tue, 7 Jul 2009 10:17:31 +0100 (BST) Received: from [192.168.0.3] (88-111-6-11.dynamic.dsl.as9105.com [88.111.6.11]) (authenticated bits=0) by mail.authsmtp.com (8.14.2/8.14.2/Kp) with ESMTP id n679HUhb027680; Tue, 7 Jul 2009 10:17:30 +0100 (BST) Subject: Re: Best way to simulate Booleans From: Simon Riggs To: Scott Marlowe Cc: Peter Headland , pgsql-sql@postgresql.org In-Reply-To: References: <71F491F5DA99604A80DE49424BF3D02B0C089039@exchange8.actuate.com> Content-Type: text/plain Date: Tue, 07 Jul 2009 10:17:02 +0100 Message-Id: <1246958222.3874.129.camel@ebony.2ndQuadrant> Mime-Version: 1.0 X-Mailer: Evolution 2.12.0 Content-Transfer-Encoding: 7bit X-Server-Quench: ff6825f7-6ad6-11de-98d8-002264978518 X-AuthRoute: OCdxZQATClZOTQEd DAteCiNZVAwpPBRK HVkIKg5MJUcNSQVJ NksadRtFaAJbZ0xd HGQLW11EUV17WGR/ aAofZQ1DY0tPQQN0 UUlWQFdQERpoT0IH ARdmN0EgdwdBfnZw K0dkW3QVChJ8fUR4 FElJEzxSY3phaTRK TUlQIwtJcANIfBlB Y1d3UXIFLwdSbGoL JDYXCngbMC5DYDtc U0kRKhoJQEMWGjcg SlgoGjIrEEQDXE0g X-Authentic-SMTP: 61633235383639.pelican.dmpriest.net.uk:1562/Kp X-Report-SPAM: If SPAM / abuse - report it at: http://www.authsmtp.com/abuse X-Virus-Status: No virus detected - but ensure you scan with your own anti-virus system. X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.008 tagged_above=0 required=5 tests=AWL=0.008 X-Spam-Level: X-Archive-Number: 200907/28 X-Sequence-Number: 32769 On Tue, 2009-07-07 at 00:13 -0600, Scott Marlowe wrote: > On Mon, Jul 6, 2009 at 7:22 PM, Peter Headland wrote: > > I know, I know, PostgreSQL has Booleans that work very nicely. > > Unfortunately, I have to create a schema that will work on Oracle as well as > > PostgreSQL, by which I mean that a single set of Java/JDBC code has to work > > with both databases. I have an XML meta-schema that enables me to generate > > appropriate DDL; that handles all the INTEGER vs. NUMBER(m,n) stuff. But > > Oracle simply has no Booleans, so I will have to resort to some more or less > > ugly alternative. I am hoping that others here have had to deal with this > > and can suggest an approach that will be minimally loathsome. > > mybool int check (mybool >=0 and <=1) Integer works best since it converts easily to boolean mybool smallint check (mybool in (0, 1)) You can use "char" also, but the syntax is less clear. -- Simon Riggs www.2ndQuadrant.com PostgreSQL Training, Services and Support