pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: tyrrill_ed@emc.com
Cc: pgsql-sql@postgresql.org
Subject: Re: Bit string help, please
Date: Thu, 06 Mar 2008 08:13:43 +0000
Message-ID: <47CFA7B7.9080902@archonet.com> (raw)
In-Reply-To: <4FB0C599D8D0B14FA37B46EAD92F2153036EEC5E@CORPUSMX60C.corp.emc.com>
References: <4FB0C599D8D0B14FA37B46EAD92F2153036EEC5E@CORPUSMX60C.corp.emc.com>

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



view thread (7+ messages)  latest in thread

Message-ID: <47CFA7B7.9080902@archonet.com>
Permalink:  ../47CFA7B7.9080902@archonet.com/
Also on:    postgresql.org/message-id/47CFA7B7.9080902@archonet.com

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: dev@archonet.com, tyrrill_ed@emc.com
  Subject: Re: Bit string help, please
  In-Reply-To: <47CFA7B7.9080902@archonet.com>

* 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