Re: Copy and xml files

From: Chris Gamache <cgg007(at)yahoo(dot)com>
To: C G <csgcsg39(at)hotmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Copy and xml files
Date: 2004-02-03 16:29:24
Message-ID: 20040203162924.86391.qmail@web13808.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

COPY works for whole tables, and can't append rows. You're going to have to
escape your linebreaks and tabs to use COPY ... As I recall, you can specify
your own custom column and row delimiters... You might consider creating some
type of primary key for the table. A "serial" column would work fine.

If you want to insert a single row into a table, you'll need to do it with an
insert statement. something like :

# psql your_database -c "insert into t1 (xml_column) values ('`cat
/tmp/file.xml | sed -e \"s/'/''/g\"`');"

HTH,

CG

--- C G <csgcsg39(at)hotmail(dot)com> wrote:
> Dear All,
>
> I'm trying to insert an xml file into my database. I have a table with a
> single text column. My intention is just to have the xml file take up one
> row in the table.
>
> I've tried the command
>
> COPY t1 FROM '/tmp/file.xml';
>
> but keep getting the error message
>
> ERROR: extra data after last expected column
> CONTEXT: COPY t1, line 32: " <cn type="integer"> 1 </cn>"
>
> Thanks for any help
>
> Colin
>
> _________________________________________________________________
> Sign-up for a FREE BT Broadband connection today!
> http://www.msn.co.uk/specials/btbroadband
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dirk Försterling 2004-02-03 17:41:15 Re: problem with jdbc connection to postgesql
Previous Message Francois Suter 2004-02-03 16:02:23 Anyone has nls activated on Mac OS X?