pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
How to convert a string to bytea?
5+ messages / 3 participants
[nested] [flat]

* How to convert a string to bytea?
@ 2006-08-30 16:22  Chris Hoover <revoohc@gmail.com>
  0 siblings, 2 replies; 5+ messages in thread

From: Chris Hoover @ 2006-08-30 16:22 UTC (permalink / raw)
  To: pgsql-admin

I am in need of some help.  I need to use the encode function against a text
string in one of my pg/plsql functions.  However, the encode function
expects a bytea field to be passed to it.  How do I convert my text string
into a bytea?

Thanks,

Chris

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

* Fwd: How to convert a string to bytea?
@ 2006-08-30 16:22  Chris Hoover <revoohc@gmail.com>
  parent: Chris Hoover <revoohc@gmail.com>
  1 sibling, 1 reply; 5+ messages in thread

From: Chris Hoover @ 2006-08-30 16:22 UTC (permalink / raw)
  To: pgsql-general@postgresql.org

---------- Forwarded message ----------
From: Chris Hoover <revoohc@gmail.com>
Date: Aug 30, 2006 12:22 PM
Subject: How to convert a string to bytea?
To: "pgsql-admin@postgresql.org" <pgsql-admin@postgresql.org>

I am in need of some help.  I need to use the encode function against a text
string in one of my pg/plsql functions.  However, the encode function
expects a bytea field to be passed to it.  How do I convert my text string
into a bytea?

Thanks,

Chris

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

* Re: How to convert a string to bytea?
@ 2006-08-30 16:23  Chris Hoover <revoohc@gmail.com>
  parent: Chris Hoover <revoohc@gmail.com>
  1 sibling, 0 replies; 5+ messages in thread

From: Chris Hoover @ 2006-08-30 16:23 UTC (permalink / raw)
  To: pgsql-admin

Sorry, this was supposed to go to the -general list.

On 8/30/06, Chris Hoover <revoohc@gmail.com> wrote:
>
> I am in need of some help.  I need to use the encode function against a
> text string in one of my pg/plsql functions.  However, the encode function
> expects a bytea field to be passed to it.  How do I convert my text string
> into a bytea?
>
> Thanks,
>
> Chris
>

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

* Re: Fwd: How to convert a string to bytea?
@ 2006-08-30 21:56  Roman Neuhauser <neuhauser@sigpipe.cz>
  parent: Chris Hoover <revoohc@gmail.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Roman Neuhauser @ 2006-08-30 21:56 UTC (permalink / raw)
  To: Chris Hoover <revoohc@gmail.com>; +Cc: pgsql-general@postgresql.org

# revoohc@gmail.com / 2006-08-30 12:22:47 -0400:
> ---------- Forwarded message ----------
> From: Chris Hoover <revoohc@gmail.com>
> Date: Aug 30, 2006 12:22 PM
> Subject: How to convert a string to bytea?
> To: "pgsql-admin@postgresql.org" <pgsql-admin@postgresql.org>
> 
> I am in need of some help.  I need to use the encode function against a text
> string in one of my pg/plsql functions.  However, the encode function
> expects a bytea field to be passed to it.  How do I convert my text string
> into a bytea?

    See decode()/encode() in
    http://www.postgresql.org/docs/8.1/static/functions-binarystring.html

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE.             http://bash.org/?255991



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

* Re: How to convert a string to bytea?
@ 2006-08-31 13:41  Markus Wollny <Markus.Wollny@computec.de>
  0 siblings, 0 replies; 5+ messages in thread

From: Markus Wollny @ 2006-08-31 13:41 UTC (permalink / raw)
  To: Chris Hoover <revoohc@gmail.com>; pgsql-admin

On 8/30/06, Chris Hoover <revoohc@gmail.com> wrote: 

>I am in need of some help.  I need to use the encode function 
> against a text string in one of my pg/plsql functions.  
> However, the encode function expects a bytea field to be 
> passed to it.  How do I convert my text string into a bytea? 
	
I use two simple plpgsql functions to convert strings to and from bytea:

CREATE OR REPLACE FUNCTION text2bytea(text)
  RETURNS bytea AS
$BODY$
begin
 return $1;
end;
$BODY$
  LANGUAGE 'plpgsql' VOLATILE;

and

CREATE OR REPLACE FUNCTION bytea2text(bytea)
  RETURNS text AS
$BODY$
begin
 return $1;
end;
$BODY$
  LANGUAGE 'plpgsql' VOLATILE;

Kind regards

   Markus

________________________________

Von: pgsql-admin-owner@postgresql.org
[mailto:pgsql-admin-owner@postgresql.org] Im Auftrag von Chris Hoover
Gesendet: Mittwoch, 30. August 2006 18:24
An: pgsql-admin@postgresql.org
Betreff: Re: [ADMIN] How to convert a string to bytea?


Sorry, this was supposed to go to the -general list.


On 8/30/06, Chris Hoover <revoohc@gmail.com> wrote: 

	I am in need of some help.  I need to use the encode function
against a text string in one of my pg/plsql functions.  However, the
encode function expects a bytea field to be passed to it.  How do I
convert my text string into a bytea? 
	
	Thanks,
	
	
	Chris
	





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


end of thread, other threads:[~2006-08-31 13:41 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-08-30 16:22 How to convert a string to bytea? Chris Hoover <revoohc@gmail.com>
2006-08-30 16:22 ` Chris Hoover <revoohc@gmail.com>
2006-08-30 21:56   ` Roman Neuhauser <neuhauser@sigpipe.cz>
2006-08-30 16:23 ` Chris Hoover <revoohc@gmail.com>
2006-08-31 13:41 Re: How to convert a string to bytea? Markus Wollny <Markus.Wollny@computec.de>

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