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

From Alvaro Herrera
Subject Re: ERROR: cannot cast type text to bit varying
Date
Msg-id 20050609225406.GA15047@surnet.cl
Whole thread Raw
In response to Re: ERROR: cannot cast type text to bit varying  (Matt Miller <mattm@epx.com>)
Responses Re: ERROR: cannot cast type text to bit varying  (Matt Miller <mattm@epx.com>)
List pgsql-general
On Thu, Jun 09, 2005 at 10:18:27PM +0000, Matt Miller wrote:
> On Thu, 2005-06-09 at 20:05 +0000, Matt Miller wrote:
> > I'm trying to interpret strings of Y's and N's as bit vectors and
> > perform bitwise ops on them.
>
> Well, I ended up writing a bunch of code to accomplish what I initially
> thought would be just some casting and bitops on built-in types.  I
> really thought that the bit string types would help me, but I just
> couldn't get them to work.

I imagine you could have done something involving textout() and
varbit_in(), like

alvherre=# select varbit_in(textout(translate('YYNY', 'YN', '10')), 123::oid, 32);
 varbit_in
-----------
 1101
(1 fila)

The OID parameter is unused, give it anything except NULL.  The integer
is the maximum length of the resulting varbit field.

--
Alvaro Herrera (<alvherre[a]surnet.cl>)
"La soledad es compañía"

pgsql-general by date:

Previous
From: Steve Atkins
Date:
Subject: Re: Version Control?
Next
From: elein@varlena.com (elein)
Date:
Subject: Re: Version Control?