in reply to Re: writing a filein thread writing a file
And, of course, add some error-checking to the database query itself...