Re: Bit string help, please

From: Richard Huxton <dev(at)archonet(dot)com>
To: tyrrill_ed(at)emc(dot)com
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Bit string help, please
Date: 2008-03-06 08:13:43
Message-ID: 47CFA7B7.9080902@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

tyrrill_ed(at)emc(dot)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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Huxton 2008-03-06 08:24:51 Re: RETURN QUERY generates error
Previous Message Yura Gal 2008-03-06 07:45:11 RETURN QUERY generates error