Re: Bit string help, please
От | Tena Sakai |
---|---|
Тема | Re: Bit string help, please |
Дата | |
Msg-id | FE44E0D7EAD2ED4BB2165071DB8E328C0378F104@egcrc-ex01.egcrc.org обсуждение исходный текст |
Ответ на | Bit string help, please (tyrrill_ed@emc.com) |
Список | pgsql-sql |
<p><font size="2">Hi Ed,<br /><br /> I tried exactly what you did and it works for me.<br /> My postgres is 8.3.0 runningon redhat advanced<br /> server. This is what it told me:<br /><br /> prompt=# SELECT ('1' || repeat('0', 7))::bitvarying;<br /> varbit <br /> ----------<br /> 10000000<br /> (1 row)<br /><br /> prompt=#<br /><br /> Regards,<br/><br /> Tena Sakai<br /> tsakai@gallo.ucsf.edu<br /><br /><br /><br /> -----Original Message-----<br /> From:pgsql-sql-owner@postgresql.org on behalf of tyrrill_ed@emc.com<br /> Sent: Thu 3/6/2008 10:24 AM<br /> To: dev@archonet.com<br/> Cc: pgsql-sql@postgresql.org<br /> Subject: Re: [SQL] Bit string help, please<br /><br /> I tried thisreal quick at the psql command prompt, and unfortunately it<br /> doesn't work:<br /><br /> mydb=# select ('1' || repeat('0',7))::bitvarying;<br /> ERROR: cannot cast type text to bit varying<br /><br /> I appreciate the try though. Any other ideas? I am using PostgreSQL<br /> 8.2.3.1. I don't know if that matters too much.<br /><br /> Thanks,<br/> Ed<br /><br /><br /> -----Original Message-----<br /> From: Richard Huxton [<a href="mailto:dev@archonet.com">mailto:dev@archonet.com</a>]<br/> Sent: Thursday, March 06, 2008 12:14 AM<br /> To: Tyrrill,Ed<br /> Cc: pgsql-sql@postgresql.org<br /> Subject: Re: [SQL] Bit string help, please<br /><br /> tyrrill_ed@emc.comwrote:<br /> ><br /> > insert into table1 values( DEFAULT, B'1'::bit( n ) );<br /> ><br /> >Where n is one of the parameters to the PL/pgSQL function, but that<br /> > doesn't work. PostgreSQL doesn't likehaving a variable for the bit<br /> > string length. Does anyone have any ideas how I could achieve this?<br /><br/> Try casting from a string:<br /> SELECT ('1' || repeat('0', n-1))::bit varying;<br /><br /><br /> --<br /> Richard Huxton<br /> Archonet Ltd<br /><br /><br /> --<br /> Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)<br/> To make changes to your subscription:<br /><a href="http://mail.postgresql.org/mj/mj_wwwusr?domain=postgresql.org&extra=pgsql-sql">http://mail.postgresql.org/mj/mj_wwwusr?domain=postgresql.org&extra=pgsql-sql</a><br /><br/></font>
В списке pgsql-sql по дате отправления: