Re: Addition and subtraction on BIT type - Mailing list pgsql-sql

From Stephan Szabo
Subject Re: Addition and subtraction on BIT type
Date
Msg-id 20031116213918.P81284@megazone.bigpanda.com
Whole thread Raw
In response to Re: Addition and subtraction on BIT type  (Yasir Malik <ymalik@cs.stevens-tech.edu>)
Responses Re: Addition and subtraction on BIT type  (Yasir Malik <ymalik@heineken.cs.stevens-tech.edu>)
List pgsql-sql
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 bit(int4(b'1001'));
>
> I get the following message:
> ERROR:  parser: parse error at or near "int4" at character 12
>
> Can anyone tell me why the bit function is not working?  It's under the
> pg_catalog schema.

It's also the name of a type that takes a precision in parentheses, so
you'd have to say "bit"(...) with the quotes. As a note, I think
that's going to effectively return you a bit(32), so

sszabo=# select "bit"(int4(b'1001'));              bit
----------------------------------00000000000000000000000000001001



pgsql-sql by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: WITHOUT OIDS by default
Next
From: Greg Stark
Date:
Subject: Re: Programatically switching database