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 21C5ED1B907 for ; Mon, 17 Nov 2003 05:41:18 +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 02633-01 for ; Mon, 17 Nov 2003 01:40:47 -0400 (AST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id 5ADBBD1B4FB for ; Mon, 17 Nov 2003 01:40:46 -0400 (AST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id C491C35427; Sun, 16 Nov 2003 21:40:45 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id C3752353FA; Sun, 16 Nov 2003 21:40:45 -0800 (PST) Date: Sun, 16 Nov 2003 21:40:45 -0800 (PST) From: Stephan Szabo To: Yasir Malik Cc: pgsql-sql@postgresql.org Subject: Re: Addition and subtraction on BIT type In-Reply-To: Message-ID: <20031116213918.P81284@megazone.bigpanda.com> 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/190 X-Sequence-Number: 16005 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