Re: [GENERAL] cast bit to boolean?

2001-05-04 Thread Vivek Khera

 RH == Robert Hentosh [EMAIL PROTECTED] writes:

RH select * from t1 where (sel_a  b'11'  b'00' );

Yep.  That solution hit me just as the head hit the pillow last night,
too!

Thanks.

---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]



Re: [GENERAL] cast bit to boolean?

2001-05-03 Thread Robert Hentosh

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'01',b'001000');
 select * from t1 where sel_a  b'11';
 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'11' = b'11' );

It seems that all bit files must be equal in length.


---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html