Skip site navigation (1) Skip section navigation (2)

Re: boolean as 0 and 1

From: "Shoaib Mir" <shoaibmir(at)gmail(dot)com>
To: "A B" <gentosaker(at)gmail(dot)com>, "Postgres novice mailing list" <pgsql-novice(at)postgresql(dot)org>
Subject: Re: boolean as 0 and 1
Date: 2008-04-08 10:03:20
Message-ID: bf54be870804080303n6927854bpf62299e6ab85c511@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-novice
On Tue, Apr 8, 2008 at 7:58 PM, Shoaib Mir <shoaibmir(at)gmail(dot)com> wrote:

> On Tue, Apr 8, 2008 at 7:54 PM, A B <gentosaker(at)gmail(dot)com> wrote:
>
> > Hi,
> > Is there a way to make postgresql to automatically convert integer
> > values to boolean?
> >
> > Consider
> >
> > create table x (a boolean);
> > insert into x (a) values (1);
> >
> > the inser fails :-(
> > Is there a way to make it work without altering the insert command?
> >
>
>
>

Try using this:

create table x (a boolean);
insert into x (a) values (1::boolean);

It worked for me in 8.3

--
Shoaib Mir
Fujitsu Australia Software Technology
shoaibm(at)fast(dot)fujitsu(dot)com(dot)au

In response to

pgsql-novice by date

Next:From: Aarni RuuhimäkiDate: 2008-04-08 10:06:13
Subject: Re: boolean as 0 and 1
Previous:From: Shoaib MirDate: 2008-04-08 09:59:15
Subject: Re: boolean as 0 and 1

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group