From: | Joe Conway <mail(at)joeconway(dot)com> |
---|---|
To: | Achilleus Mantzios <achill(at)matrix(dot)gatewaynet(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Encoding bytea |
Date: | 2004-03-03 22:59:14 |
Message-ID: | 40466342.1000608@joeconway.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Achilleus Mantzios wrote:
> is there a way to encode a bytea in such a way that the resulting
> text stream be readily available (\\ escaped for unprintable chars) for
> usage in an insert statement?
>
> None of base64,hex,escape options in encode() seem to produce
> anything close.
>
> This is meant to be used with generating insert statements in xml files
> for remote processing.
Is this what you need?
create table t(f bytea);
insert into b values ('a\\003\\000\\001b');
create or replace function bytea2text(bytea) returns text as '
begin
return $1;
end;
' language plpgsql;
regression=# select 'insert into t values(' ||
quote_literal(bytea2text(f)) || ');' from t;
?column?
--------------------------------------------
insert into t values('a\\003\\000\\001b');
(1 row)
regression=# insert into t values('a\\003\\000\\001b');
INSERT 292656 1
HTH,
Joe
From | Date | Subject | |
---|---|---|---|
Next Message | William Anthony Lim | 2004-03-04 06:29:07 | calling function |
Previous Message | Achilleus Mantzios | 2004-03-03 13:12:39 | Encoding bytea |