Unix Technical Forum

Re: How to convert a string to bytea?

This is a discussion on Re: How to convert a string to bytea? within the pgsql Admins forums, part of the PostgreSQL category; --> On 8/30/06, Chris Hoover <revoohc@gmail.com> wrote: >I am in need of some help. I need to use the encode ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Admins

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-10-2008, 06:33 AM
Markus Wollny
 
Posts: n/a
Default Re: How to convert a string to bytea?

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
[mailtogsql-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




---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:44 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com