Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id D76EE2E00C8 for ; Thu, 6 Mar 2008 04:13:55 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 49889-01 for ; Thu, 6 Mar 2008 04:13:48 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from pih-relay05.plus.net (pih-relay05.plus.net [212.159.14.132]) by postgresql.org (Postfix) with ESMTP id 2F6E32E00BA for ; Thu, 6 Mar 2008 04:13:51 -0400 (AST) Received: from [84.51.143.99] (helo=server3.office.archonet.com) by pih-relay05.plus.net with esmtp (Exim) id 1JXBEY-0006ZX-O0; Thu, 06 Mar 2008 08:13:46 +0000 Received: from [192.168.1.36] (dell36.office.archonet.com [192.168.1.36]) by server3.office.archonet.com (Postfix) with ESMTP id 35F84274060; Thu, 6 Mar 2008 08:13:43 +0000 (GMT) Message-ID: <47CFA7B7.9080902@archonet.com> Date: Thu, 06 Mar 2008 08:13:43 +0000 From: Richard Huxton User-Agent: Thunderbird 2.0.0.12 (X11/20080213) MIME-Version: 1.0 To: tyrrill_ed@emc.com CC: pgsql-sql@postgresql.org Subject: Re: Bit string help, please References: <4FB0C599D8D0B14FA37B46EAD92F2153036EEC5E@CORPUSMX60C.corp.emc.com> In-Reply-To: <4FB0C599D8D0B14FA37B46EAD92F2153036EEC5E@CORPUSMX60C.corp.emc.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Plusnet-Relay: d78c0d463b8670f2f0b5d6677457c669 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200803/23 X-Sequence-Number: 30351 tyrrill_ed@emc.com wrote: > > insert into table1 values( DEFAULT, B'1'::bit( n ) ); > > Where n is one of the parameters to the PL/pgSQL function, but that > doesn't work. PostgreSQL doesn't like having a variable for the bit > string length. Does anyone have any ideas how I could achieve this? Try casting from a string: SELECT ('1' || repeat('0', n-1))::bit varying; -- Richard Huxton Archonet Ltd