| From: | "Willy-Bas Loos" <willybas(at)gmail(dot)com> |
|---|---|
| To: | "Albe Laurenz" <all(at)adv(dot)magwien(dot)gv(dot)at> |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: cast bytea to text |
| Date: | 2007-03-01 17:42:27 |
| Message-ID: | 1dd6057e0703010942w176e34a9sa362c68e1198343a@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
yep, sry it took me a while to answer. It works now.
here´s my code:
-- start code --
create or replace function bytea2text(bytea) returns text as
$$
select ENCODE($1, 'escape');
$$
language sql strict;
create cast (bytea as text)
with function bytea2text(bytea)
as implicit;
-- end code --
thanks!
Willy-Bas Loos
On 3/1/07, Albe Laurenz <all(at)adv(dot)magwien(dot)gv(dot)at> wrote:
>
> > How can i cast bytea to text?
> > I´ve read about the DECODE function, but my 8.1 backend
> > doesn´t recognize it.
> > I´m trying to create an implicit cast using the function:
> >
> > create or replace function bytea2text(bytea) returns text as
> > $$
> > select DECODE($1, 'escape');
> > $$
> > language sql strict;
> >
> > Answer:
> > ERROR: function decode(bytea, "unknown") does not exist
>
> Try ENCODE instead of DECODE ...
>
> Yours,
> Laurenz Albe
>
| From | Date | Subject | |
|---|---|---|---|
| Next Message | David Legault | 2007-03-01 17:47:01 | Re: get username of user calling function? |
| Previous Message | George Nychis | 2007-03-01 17:35:29 | Re: get username of user calling function? |