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

--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://mail.postgresql.org/mj/mj_wwwusr?domain=postgresql.org&extra=pgsql-sql

Reply via email to