2012/2/6 zoulx1982 <zoulx1...@163.com>: > hi, > there is a problem about type cast that i don't understand, follow is my > test. > > postgres=# select 10::bit(3); > bit > ----- > 010 > (1 row) > postgres=# select 10::bit varying(3); > ERROR: cannot cast type integer to bit varying > LINE 1: select 10::bit varying(3); > ^ > postgres=# > > my question is why int can cast to bit , but bot for bit varying? > i want to know the reason. > thank you for your timing.
Off the top of my head, I'm guessing that it's just a case of nobody having implemented it. You can do this: rhaas=# select 10::bit(3)::varbit; varbit -------- 010 (1 row) -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers