X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 70F78D1B4FB for ; Mon, 17 Nov 2003 02:02:42 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 54244-10 for ; Sun, 16 Nov 2003 22:02:14 -0400 (AST) Received: from guinness.cs.stevens-tech.edu (guinness.cs.stevens-tech.edu [155.246.89.8]) by svr1.postgresql.org (Postfix) with ESMTP id 448FBD1E34B for ; Sun, 16 Nov 2003 22:02:10 -0400 (AST) Received: by guinness.cs.stevens-tech.edu (Postfix, from userid 4405) id C97F614387F; Sun, 16 Nov 2003 21:02:15 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by guinness.cs.stevens-tech.edu (Postfix) with ESMTP id B5888C2468 for ; Sun, 16 Nov 2003 21:02:15 -0500 (EST) Date: Sun, 16 Nov 2003 21:02:15 -0500 From: Yasir Malik To: pgsql-sql@postgresql.org Subject: Re: Addition and subtraction on BIT type In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200311/188 X-Sequence-Number: 16003 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 > 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 >