ERROR: cannot cast type text to bit varying - Mailing list pgsql-general

From Matt Miller
Subject ERROR: cannot cast type text to bit varying
Date
Msg-id 1118347502.3596.32.camel@dbamm01-linux
Whole thread Raw
Responses Re: ERROR: cannot cast type text to bit varying
Re: ERROR: cannot cast type text to bit varying
List pgsql-general
I'm trying to interpret strings of Y's and N's as bit vectors and
perform bitwise ops on them.  It's not working:

========beginning of output=============================
test=# select version ();
                                                 version
----------------------------------------------------------------------------------------------------------
 PostgreSQL 8.0.3 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.2.3
20030502 (Red Hat Linux 3.2.3-49)
(1 row)

test=# select translate ('YNNY', 'YN', '10')::bit varying & translate
('NYYN', 'YN', '10')::bit varying;
ERROR:  cannot cast type text to bit varying
========end of output=============================

It's curious to me that the following is fine:

========beginning of output=============================
test=# select '1001'::bit varying;
 varbit
--------
 1001
(1 row)
========end of output=============================

As what data type is the literal '1001' being treated, that it can be
cast to bit varying, while text data (e.g. the result of "translate")
cannot be so cast?

pgsql-general by date:

Previous
From: "Joshua D. Drake"
Date:
Subject: Re: monetary data
Next
From: Matt Miller
Date:
Subject: Re: ERROR: cannot cast type text to bit varying