Bit string help, please

From: tyrrill_ed(at)emc(dot)com
To: <pgsql-sql(at)postgresql(dot)org>
Subject: Bit string help, please
Date: 2008-03-05 22:17:46
Message-ID: 4FB0C599D8D0B14FA37B46EAD92F2153036EEC5E@CORPUSMX60C.corp.emc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hey PostgreSQL Gurus,

I am experimenting with PostgreSQL bit strings to see if they might help
with some performance issues I am having. I added a "bit varying"
column to one of my tables. I have a PL/pgSQL function with an insert
statement into this table. For the bit varying column I would like to
insert a bit string of length n with the highest order bit being 1 and
all the other bits being 0. Given a table definition:

create table table1 (
a int,
b bit varying
);

I hoped I could use the feature where casting right pads 0s to do
something like this:

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?

Thanks,
Ed Tyrrill

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Yura Gal 2008-03-06 07:45:11 RETURN QUERY generates error
Previous Message Jeff Frost 2008-03-05 20:03:03 Re: finding columns that have three or fewer distinct characters