Re: Any functions to convert bit(5) to text? - Mailing list pgsql-general

From Michael Fuhr
Subject Re: Any functions to convert bit(5) to text?
Date
Msg-id 20050210070031.GA59628@winnie.fuhr.org
Whole thread Raw
In response to Any functions to convert bit(5) to text?  (Együd Csaba <csegyud@vnet.hu>)
Responses Re: Any functions to convert bit(5) to text?
List pgsql-general
On Thu, Feb 10, 2005 at 07:32:35AM +0100, Együd Csaba wrote:
>
> In case of arrays I can use array_to_string(), but I couldn't find any
> functions to convert bit(*) to string (in a format like this: e.g. '10011').

I don't know if this will always work, but with current implementations
of PL/pgSQL you can do this:

CREATE FUNCTION bit2text(bit) RETURNS text AS '
BEGIN
    RETURN $1;
END;
' LANGUAGE plpgsql IMMUTABLE STRICT;

See also CREATE CAST.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

pgsql-general by date:

Previous
From: Együd Csaba
Date:
Subject: Any functions to convert bit(5) to text?
Next
From: Michael Fuhr
Date:
Subject: Re: Any functions to convert bit(5) to text?