Re: Help : insert a bytea data into new table

From: Ben Morrow <ben(at)morrow(dot)me(dot)uk>
To: dennis(dot)mails(at)gmail(dot)com, pgsql-sql(at)postgresql(dot)org
Subject: Re: Help : insert a bytea data into new table
Date: 2010-03-11 18:00:02
Message-ID: 20100311180002.GA54548@osiris.mauzo.dyndns.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

[quoting fixed]

Quoth dennis <dennis(dot)mails(at)gmail(dot)com>:
> Ben Morrow wrote:
> > Quoth dennis<dennis(at)teltel(dot)com>:
> >> Dear Ben
> >>
> >> thanks for you anwser.
> >> I try to add function quote_literal on my sql statement .
> >>
> >> but it raise other error message (quote_literal not support bytea format):
> >> function quote_literal(bytea) does not exist
> >
> > Which Postgres version are you using?
>
> Postgres : 8.1.4

Then I think you want

create function quote_literal (bytea)
returns text
immutable strict
language plpgsql
as $$
begin
return 'E'''
|| replace(encode($1, 'escape'), E'\\', E'\\\\')
|| '''';
end;
$$;

Ben

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tony Wasson 2010-03-11 22:20:54 Re: Remote monitoring of Postgres w/minimal grants
Previous Message Garrett Murphy 2010-03-11 16:33:59 Re: Trigger on select :-(