Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id B550363456A for ; Tue, 7 Jul 2009 03:14:03 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 61359-06 for ; Tue, 7 Jul 2009 03:13:48 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-ew0-f223.google.com (mail-ew0-f223.google.com [209.85.219.223]) by mail.postgresql.org (Postfix) with ESMTP id 7B4186339A7 for ; Tue, 7 Jul 2009 03:13:47 -0300 (ADT) Received: by ewy23 with SMTP id 23so2184440ewy.19 for ; Mon, 06 Jul 2009 23:13:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=UkvMn56/qj3EFFZmZPwshKyDpCcZ8zIJU4MmT9D/jsU=; b=bltkQ9ftggVmQuI9cl36Z2DnCCNmKA/pH9pZYJaS/0rItw63Zwaf3A69v8PRhAyq3E e/IigMVijsMJQ65P3bbBN5mMSrpz83qVbxVMZwMBsWJQm/DpGUOUCNbo74/UJ8CyCmQ2 bNe1j50o3wJD2DG5yVEwGTJVGdvwEy9Oh69eY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=lzAM4wJBCYIAED9gGgK89Soq31WTCzuXl16VhIc35LllqBHKr/XFjZMtBs6OZc7i99 CuLIC8JNF4yx6GIGYQFD0wrBfqy8PDg2WMgbkQ+bW4254dJ77KzXaWlqHus503ux+N0I 6Sk+KNlGRdVj7NGNXCfY8pfqtB17hnx7ABBaQ= MIME-Version: 1.0 Received: by 10.211.195.15 with SMTP id x15mr5942735ebp.59.1246947226620; Mon, 06 Jul 2009 23:13:46 -0700 (PDT) In-Reply-To: <71F491F5DA99604A80DE49424BF3D02B0C089039@exchange8.actuate.com> References: <71F491F5DA99604A80DE49424BF3D02B0C089039@exchange8.actuate.com> Date: Tue, 7 Jul 2009 00:13:46 -0600 Message-ID: Subject: Re: Best way to simulate Booleans From: Scott Marlowe To: Peter Headland Cc: pgsql-sql@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200907/26 X-Sequence-Number: 32767 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. The most transportable method would be to use either a char(1) or an int with a check constraint. mybool char(1) check (mybool in ('t','f')) mybool int check (mybool >=0 and <=1) Or something like that.