| From: | Simon Riggs <simon(at)2ndQuadrant(dot)com> | 
|---|---|
| To: | Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com> | 
| Cc: | Peter Headland <pheadland(at)actuate(dot)com>, pgsql-sql(at)postgresql(dot)org | 
| Subject: | Re: Best way to simulate Booleans | 
| Date: | 2009-07-07 09:17:02 | 
| Message-ID: | 1246958222.3874.129.camel@ebony.2ndQuadrant | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-sql | 
On Tue, 2009-07-07 at 00:13 -0600, Scott Marlowe wrote:
> On Mon, Jul 6, 2009 at 7:22 PM, Peter Headland<pheadland(at)actuate(dot)com> 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Greg Stark | 2009-07-07 09:26:30 | Re: Best way to simulate Booleans | 
| Previous Message | Dirk Jagdmann | 2009-07-07 09:05:15 | Re: Best way to simulate Booleans |