ERROR: cannot cast type text to bit varying

From: Matt Miller <mattm(at)epx(dot)com>
To: PostgreSQL - GENERAL <pgsql-general(at)postgresql(dot)org>
Subject: ERROR: cannot cast type text to bit varying
Date: 2005-06-09 20:05:02
Message-ID: 1118347502.3596.32.camel@dbamm01-linux
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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?

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Matt Miller 2005-06-09 20:16:42 Re: ERROR: cannot cast type text to bit varying
Previous Message Joshua D. Drake 2005-06-09 19:46:41 Re: monetary data