From: | "Tena Sakai" <tsakai(at)gallo(dot)ucsf(dot)edu> |
---|---|
To: | <tyrrill_ed(at)emc(dot)com>, <dev(at)archonet(dot)com> |
Cc: | <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: Bit string help, please |
Date: | 2008-03-06 18:50:43 |
Message-ID: | FE44E0D7EAD2ED4BB2165071DB8E328C0378F104@egcrc-ex01.egcrc.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Hi Ed,
I tried exactly what you did and it works for me.
My postgres is 8.3.0 running on redhat advanced
server. This is what it told me:
prompt=# SELECT ('1' || repeat('0', 7))::bit varying;
varbit
----------
10000000
(1 row)
prompt=#
Regards,
Tena Sakai
tsakai(at)gallo(dot)ucsf(dot)edu
-----Original Message-----
From: pgsql-sql-owner(at)postgresql(dot)org on behalf of tyrrill_ed(at)emc(dot)com
Sent: Thu 3/6/2008 10:24 AM
To: dev(at)archonet(dot)com
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: [SQL] Bit string help, please
I tried this real quick at the psql command prompt, and unfortunately it
doesn't work:
mydb=# select ('1' || repeat('0',7))::bit varying;
ERROR: cannot cast type text to bit varying
I appreciate the try though. Any other ideas? I am using PostgreSQL
8.2.3.1. I don't know if that matters too much.
Thanks,
Ed
-----Original Message-----
From: Richard Huxton [mailto:dev(at)archonet(dot)com]
Sent: Thursday, March 06, 2008 12:14 AM
To: Tyrrill, Ed
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: [SQL] Bit string help, please
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
--
Sent via pgsql-sql mailing list (pgsql-sql(at)postgresql(dot)org)
To make changes to your subscription:
http://mail.postgresql.org/mj/mj_wwwusr?domain=postgresql.org&extra=pgsql-sql
From | Date | Subject | |
---|---|---|---|
Next Message | tyrrill_ed | 2008-03-06 18:52:05 | Re: Bit string help, please |
Previous Message | Richard Huxton | 2008-03-06 18:35:51 | Re: Bit string help, please |