pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Yasir Malik <ymalik@cs.stevens-tech.edu>
To: pgsql-sql@postgresql.org
Subject: Re: Addition and subtraction on BIT type
Date: Sun, 16 Nov 2003 21:02:15 -0500
Message-ID: <Pine.SGI.4.58.0311162055350.144387@guinness.cs.stevens-tech.edu> (raw)
In-Reply-To: <Pine.SGI.4.58.0311161117410.129151@guinness.cs.stevens-tech.edu>
References: <Pine.SGI.4.58.0311161117410.129151@guinness.cs.stevens-tech.edu>

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:
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.
Thanks,
Yasir

On Sun, 16 Nov 2003, Yasir Malik wrote:

> Date: Sun, 16 Nov 2003 11:18:03 -0500
> From: Yasir Malik <ymalik@cs.stevens-tech.edu>
> To: pgsql-sql@postgresql.org
> Subject: Addition and subtraction on BIT type
>
> 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
> example change a 1 to a 0 or vice versa.
>
> Any suggestions?
> Thanks,
> Yasir
>



view thread (7+ messages)  latest in thread

Message-ID: <Pine.SGI.4.58.0311162055350.144387@guinness.cs.stevens-tech.edu>
Permalink:  ../Pine.SGI.4.58.0311162055350.144387@guinness.cs.stevens-tech.edu/
Also on:    postgresql.org/message-id/Pine.SGI.4.58.0311162055350.144387@guinness.cs.stevens-tech.edu

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: ymalik@cs.stevens-tech.edu
  Subject: Re: Addition and subtraction on BIT type
  In-Reply-To: <Pine.SGI.4.58.0311162055350.144387@guinness.cs.stevens-tech.edu>
  References: <Pine.SGI.4.58.0311161117410.129151@guinness.cs.stevens-tech.edu> <Pine.SGI.4.58.0311162055350.144387@guinness.cs.stevens-tech.edu>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox