pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
SQL repr of bytea val
2+ messages / 2 participants
[nested] [flat]

* SQL repr of bytea val
@ 2005-06-20 13:47  Markus Bertheau ☭ <twanger@bluetwanger.de>
  0 siblings, 1 reply; 2+ messages in thread

From: Markus Bertheau ☭ @ 2005-06-20 13:47 UTC (permalink / raw)
  To: pgsql-sql

Hi,

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?

Markus

-- 
Markus Bertheau ☭ <twanger@bluetwanger.de>




^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: SQL repr of bytea val
@ 2005-06-21 00:12  Michael Fuhr <mike@fuhr.org>
  parent: Markus Bertheau ☭ <twanger@bluetwanger.de>
  0 siblings, 0 replies; 2+ messages in thread

From: Michael Fuhr @ 2005-06-21 00:12 UTC (permalink / raw)
  To: Markus Bertheau ??? <twanger@bluetwanger.de>; +Cc: 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/



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2005-06-21 00:12 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-06-20 13:47 SQL repr of bytea val Markus Bertheau ☭ <twanger@bluetwanger.de>
2005-06-21 00:12 ` Michael Fuhr <mike@fuhr.org>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox