Inserting large binary data into lo type table

From: Jose Moreira <jgmoreira(at)anda(dot)com(dot)uy>
To: pgsql-general(at)postgresql(dot)org
Subject: Inserting large binary data into lo type table
Date: 2014-08-12 13:20:59
Message-ID: 53EA14BB.8070403@anda.com.uy
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I guess this is easy a question for the gurus, but afraid I cannot get
te answer!

I have this table:

aif_test=# \d sbox;
Table "public.sbox"
Column | Type | Modifiers
--------+------------------------+-----------
id | character varying(255) | not null
data | lo |
Indexes:
"sbox_pkey" PRIMARY KEY, btree (id)

And trying to insert a binary file which I show only the first lines:

Emitidas/10001.doc|\\x3C3F786D6C2076657273696F6E3D22312E302220656E636F64696E673D225554462D38223F3E0A3C41434B43464520786D6C6E733D22687474703A2F2F6366652E646769
2E6775622E75792220786D6C6E733A6E73323D22687474703A2F2F7777772E77332E6F72672F323030302F30392F786D6C64736967232220786D6C6E733A7873693D22687474703A2F2F7777772E77332E6F726
72F323030312F584D4C536368656D612D696E7374616E6365222076657273696F6E3D22312E3

When runing a simple insert I get:

[postgres(at)dbfactura01dmz /tmp]$ psql -d aif_test -U aif <
subida_postgres_copys_sbox.sql
Password for user aif:
ERROR: invalid input syntax for type oid:
\x3C3F786D6C2076657273696F6E3D22312E302220656E636F64696E673D225554462D38223F3E0A3C41434B43464520786D6C6E733D22687474703A2F2F6366652E6.............

sql script:
[postgres(at)dbfactura01dmz /tmp]$ more subida_postgres_copys_sbox.sql
COPY sbox FROM '/tmp/TXT/SBOX.txt' WITH DELIMITER '|' NULL '';

I am not able to insert a simple binary text into a "lo" type column!!!
Read on the doc but it should work thoug. Any help please??

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2014-08-12 13:29:06 Re: Inserting large binary data into lo type table
Previous Message Jimmy Thrasibule 2014-08-12 13:19:16 PostgreSQL as a triple store