Re: Any functions to convert bit(5) to text?

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Együd Csaba <csegyud(at)vnet(dot)hu>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Any functions to convert bit(5) to text?
Date: 2005-02-10 07:00:31
Message-ID: 20050210070031.GA59628@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michael Fuhr 2005-02-10 07:16:53 Re: Any functions to convert bit(5) to text?
Previous Message Együd Csaba 2005-02-10 06:32:35 Any functions to convert bit(5) to text?