From: | Robert Hentosh <hentosh(at)io(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: cast bit to boolean? |
Date: | 2001-05-03 22:08:14 |
Message-ID: | 20010503170814.D25704@fnord.io.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Thu, May 03, 2001 at 05:25:14PM -0400, Vivek Khera wrote:
> How might one case a BIT to a BOOLEAN? For example, I want to return
> rows which have non-zero bit representation for, say, (sel_a & b'0011').
> That is, rows with the first or second bit set.
>
> I tried an explicit CAST, and just the query directly, but the cast
> say you cant cast type 'bit' to 'bool', and the direct query says
> WHERE clause must return type bool, not type bit:
>
> create table t1 (sel_a BIT(6),sel_b BIT(6));
> insert into t1 values (b'000001',b'001000');
> select * from t1 where sel_a & b'100001';
> ERROR: WHERE clause must return type bool, not type bit
>
> Where might I look for this? The manual is quite sparse regarding BIT
> types.
>
> Thanks.
If you want only the rows where both bits are set then try:
select * from t1 where ( sel_a & b'100001' = b'100001' );
It seems that all bit files must be equal in length.
From | Date | Subject | |
---|---|---|---|
Next Message | Trond Eivind =?iso-8859-1?q?Glomsr=F8d?= | 2001-05-03 22:10:40 | Re: Ideal hardware configuration for pgsql/Netra |
Previous Message | Trond Eivind =?iso-8859-1?q?Glomsr=F8d?= | 2001-05-03 22:07:07 | Re: Ideal hardware configuration for pgsql |