insert bytea data manually

Lists: pgsql-jdbc
From: Muhlis Akdag <mican58(at)gmail(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: insert bytea data manually
Date: 2005-10-03 21:10:18
Message-ID: 43419E3A.5090307@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Hi,

I have a question about bytea columns. I want manually select the
column.. this looks like this..when I export it from pgadmin into a csv
file..
"10";"PK\003\004\024\000\000\000\000\000\214\22453\341\24519\036\000\000\000\03.........."

so how I can inert it back to the database manually.. like this..

insert into files (docid,file) values
(1,'PK\003\004\024\000\000\000\000\000\214\22453\341\24519\036\000\000\000\03..........")

but it brings error when i try this..?

can sombody help me how i can extract bytea data and insert it back
manually with SQL commands?


From: Kris Jurka <books(at)ejurka(dot)com>
To: Muhlis Akdag <mican58(at)gmail(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: insert bytea data manually
Date: 2005-10-03 23:01:13
Message-ID: Pine.BSO.4.61.0510031759030.30667@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

On Mon, 3 Oct 2005, Muhlis Akdag wrote:

> I have a question about bytea columns. I want manually select the column..
> this looks like this..when I export it from pgadmin into a csv file..
> "10";"PK\003\004\024\000\000\000\000\000\214\22453\341\24519\036\000\000\000\03.........."
>
> so how I can inert it back to the database manually.. like this..
>
> insert into files (docid,file) values
> (1,'PK\003\004\024\000\000\000\000\000\214\22453\341\24519\036\000\000\000\03..........")
>

See the documentation for the correct escapting you will need.

http://www.postgresql.org/docs/8.0/static/datatype-binary.html

You need to double the backslashes when sending the data to the backend.

Kris Jurka