Re: [GENERAL] UPDATE cell from text file
От | Bob Kline |
---|---|
Тема | Re: [GENERAL] UPDATE cell from text file |
Дата | |
Msg-id | Pine.LNX.4.10.9910232028300.28391-100000@rksystems.com обсуждение исходный текст |
Ответ на | UPDATE cell from text file ("Jason C. Wells" <jcwells@u.washington.edu>) |
Ответы |
Re: [GENERAL] UPDATE cell from text file
|
Список | pgsql-general |
On Sun, 24 Oct 1999, Jason C. Wells wrote: > This has got to be easy but I am having a hard time finding the right > docs. > > What I want to do is analogous to: > > UPDATE website SET content='contents of a big ass file that I dont want to > type on the command line' where filename='index.html'; > > How can I do this? > > Can I do this without writing a seperate shell and/or perl script? > > Also, is there a stdio stream that I can use to pipe data into SQL > commands? Man, If I had this I could get a lot done in a hurry. > > FWIW, I am not looking for COPY-ing delimited data from a flat file into a > table. I don't want to make new rows. I am trying to bring the contents of > an entire file into an existing single cell (namely content) of a table. > > Am I going to be stuck just putting pointers to files in my database? Ugg, > I really want ALL my data in one place. > Just out of curiosity, what's the drawback of a perl script here? It would be pretty trivial. .... open BAF, "$ARGV[0]" or die "Can't open $ARGV[0]: $!"; $contents = ""; while (read, BAF, $buf, 10240) { $contents .= $buf; } $sth = $dbh->prepare("UPDATE website SET content = ? WHERE filename = ?"); $sth->execute($content, $ARGV[1]) or die $DBI::errstr; .... -- Bob Kline mailto:bkline@rksystems.com http://www.rksystems.com
В списке pgsql-general по дате отправления: