Re: How to store text files in the postgresql? - Mailing list pgsql-general

From DimitryASuplatov
Subject Re: How to store text files in the postgresql?
Date
Msg-id 1244295440.8823.26.camel@leiden.genebee.msu.ru
Whole thread Raw
In response to How to store text files in the postgresql?  (DimitryASuplatov <genesup@gmail.com>)
List pgsql-general
Thank you for answering.

I`ve read a manual and now I have a more advanced question.

1/ I`ve created a table in the database

mypdb=# create table pdb(
index int,
filename text,
filecontent text
);

2/ Then I want to read a file into it

First I insert metainfo

mypdb=# insert into pdb (index , filename) values (1,
'/home/sda/Documents/Work/PVA_India/PGA_test_modeling/pdb/1gm9.pdb');
INSERT 0 1

But then comes the problem because the only command I found to read in
the file content is COPY but the following command would not work

mypdb=# copy pdb (filecontent) from
'/home/sda/Documents/Work/PVA_India/PGA_test_modeling/pdb/1gm9.pdb'
where index=1;
ERROR:  syntax error at or near "where"
LINE 1: ...ts/Work/PVA_India/PGA_test_modeling/pdb/1gm9.pdb' where
inde...


QUESTION: what is the command to read the content of a plain text file
into a SPECIFIED table entry?

Thank you for your time.
SDA




pgsql-general by date:

Previous
From: "Leif B. Kristensen"
Date:
Subject: Re: limit table to one row
Next
From: Martin Gainty
Date:
Subject: Re: PostgreSQL and XA Distributed Transaction Protocol