pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Simon Riggs <simon@2ndQuadrant.com>
To: Scott Marlowe <scott.marlowe@gmail.com>
Cc: Peter Headland <pheadland@actuate.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Best way to simulate Booleans
Date: Tue, 07 Jul 2009 10:17:02 +0100
Message-ID: <1246958222.3874.129.camel@ebony.2ndQuadrant> (raw)
In-Reply-To: <dcc563d10907062313j1f0eb27awc2bea6b3f810dc41@mail.gmail.com>
References: <71F491F5DA99604A80DE49424BF3D02B0C089039@exchange8.actuate.com>
	<dcc563d10907062313j1f0eb27awc2bea6b3f810dc41@mail.gmail.com>


On Tue, 2009-07-07 at 00:13 -0600, Scott Marlowe wrote:
> On Mon, Jul 6, 2009 at 7:22 PM, Peter Headland<pheadland@actuate.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




view thread (5+ messages)  latest in thread

Message-ID: <1246958222.3874.129.camel@ebony.2ndQuadrant>
Permalink:  ../1246958222.3874.129.camel@ebony.2ndQuadrant/
Also on:    postgresql.org/message-id/1246958222.3874.129.camel@ebony.2ndQuadrant

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: simon@2ndQuadrant.com, scott.marlowe@gmail.com, pheadland@actuate.com
  Subject: Re: Best way to simulate Booleans
  In-Reply-To: <1246958222.3874.129.camel@ebony.2ndQuadrant>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox