[SQL] Addition and subtraction on BIT type

2003-11-19 Thread Yasir Malik
Hello, Is there a way to do addition and subtraction on BIT types? For example, for creat table test (a BIT(3)); insert into test values (B'101'); select a + 1 from test; fails and select a::smallint + 1 from test; also fails. In addition, is there a way to change the bit of a bit string? For

Re: [SQL] Addition and subtraction on BIT type

2003-11-18 Thread Yasir Malik
manipulation. Thanks, Yasir On Sun, 16 Nov 2003, Stephan Szabo wrote: Date: Sun, 16 Nov 2003 21:40:45 -0800 (PST) From: Stephan Szabo [EMAIL PROTECTED] To: Yasir Malik [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: [SQL] Addition and subtraction on BIT type On Sun, 16 Nov 2003, Yasir Malik

Re: [SQL] Addition and subtraction on BIT type

2003-11-17 Thread Yasir Malik
manipulation. Thanks, Yasir On Sun, 16 Nov 2003, Stephan Szabo wrote: Date: Sun, 16 Nov 2003 21:40:45 -0800 (PST) From: Stephan Szabo [EMAIL PROTECTED] To: Yasir Malik [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: [SQL] Addition and subtraction on BIT type On Sun, 16 Nov 2003, Yasir Malik

Re: [SQL] Addition and subtraction on BIT type

2003-11-17 Thread Stephan Szabo
On Mon, 17 Nov 2003, Yasir Malik wrote: Thank you for your reply. select int4(b'1001')::bit(32); gives the same result as what you gave. select int4(b'1001')::bit(4); gives the upper four bits, which are all zeroes. How would I get the lower four bits? I building bitmaps using plpgsql, and

[SQL] Addition and subtraction on BIT type

2003-11-16 Thread Yasir Malik
Hello, Is there a way to do addition and subtraction on BIT types? For example, for creat table test (a BIT(3)); insert into test values (B'101'); select a + 1 from test; fails and select a::smallint + 1 from test; also fails. In addition, is there a way to change the bit of a bit string? For

Re: [SQL] Addition and subtraction on BIT type

2003-11-16 Thread Yasir Malik
Hello, I think I am almost at a solution to my last question. I can do select int4(a) from test; to convert to an integer. So now addition and subtraction can be done between bit types. But how do I convert back to BIT type? If I do select bit(int4(b'1001')); I get the following message:

Re: [SQL] Addition and subtraction on BIT type

2003-11-16 Thread Stephan Szabo
On Sun, 16 Nov 2003, Yasir Malik wrote: I think I am almost at a solution to my last question. I can do select int4(a) from test; to convert to an integer. So now addition and subtraction can be done between bit types. But how do I convert back to BIT type? If I do select