Re: SQL repr of bytea val

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Markus Bertheau ??? <twanger(at)bluetwanger(dot)de>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: SQL repr of bytea val
Date: 2005-06-21 00:12:40
Message-ID: 20050621001240.GA28117@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Mon, Jun 20, 2005 at 03:47:01PM +0200, Markus Bertheau ??? wrote:
>
> I'm constructing querys on the fly in PL/pgSQL_ and need a function that
> returns the SQL representation of a bytea value. I tried encode(..,
> 'escape') but it seems to return 8 bit ASCII values, not the \377 stuff
> that's supposed to be in the bytea input syntax. Does anyone know a way
> to do that?

How about textin(byteaout(bytea_value))? Or a function that performs
the conversion by magic:

CREATE FUNCTION bytea2text(bytea) RETURNS text AS $$
BEGIN
RETURN $1;
END;
$$ LANGUAGE plpgsql IMMUTABLE STRICT;

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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Zac 2005-06-21 09:54:41 SELECT INTO returning more than one row
Previous Message Michael Fuhr 2005-06-20 23:36:44 Re: Array in plpgsql with composite type