inserting/updating a field with the contents of a text file

From: "Lonni J Friedman" <netllama(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: inserting/updating a field with the contents of a text file
Date: 2007-09-24 23:57:34
Message-ID: 7c1574a90709241657lf06fe7bx29be6542d04d2762@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Greetings,
I've googled a bit on this, and didn't find any clear answers. I've
got a table with several columns, one of which I'd like to hold the
contents of text files. What I tried doing was using psql to do
something like:
psql -q -d database0 -h server -c "UPDATE table set info='`cat
/tmp/file.txt`' where id=3;"

and this almost works. The problem is that whenever there are
carriage returns in file.txt, the rest of the file contents never get
inserted (i only get the first line).

It seems like i'd need to somehow escape out the carriage returns, but
I"m not sure how to do this without altering the contents of file.txt.

thanks for any pointers.

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message George Pavlov 2007-09-25 00:27:32 Re: inserting/updating a field with the contents of a text file
Previous Message Oliver Elphick 2007-09-24 21:41:42 Re: Odbc connection