Re: Inserting LOB into DB2 in pieces



No, I didn't mean to imply that the web user's file has already been uploaded and saved in a file on the Apache server.

Good point about the multiple trips between the Apache server and the DBMS. Although the 1024 was arbitrary, I could have made that bigger like 32K.

Thanks for the feedback.

Jonathan Leffler <jonathan.leffler@xxxxxxxxx> wrote: On Thu, Mar 6, 2008 at 8:25 PM, Bong Tumanut wrote:

I'm writing an Apache::ASP program to upload a file and store it in a LOB
column in DB2. Is there a way to store the uploaded file in pieces, i.e.


while(read($filehandle, $data, 1024))
{
# data from the uploaded file read into $data
# load all $data into a LOB column
};
I know the uploaded file can be stored in a file and then the file, in
turn, is bound to a LOB column. But this is extra processing.

I also know that I can store the whole file in a variable but that could
take up a lot of memory.




Round trips to the database are expensive too. I'd go with store the whole
LOB in a file and then bind that to the LOB - it will be be less stress on
the system overall, I think. It depends slightly on the size of the files
on average, but if you're going to do more than two round trips in fragments
(more than 2 KB files/LOBs), then you should think again.

Also, your comments imply the data is already in an uploaded file - so
aren't you making busy work for yourself?

And, I strongly suspect this would apply to any DBMS where the client is in
a separate process from the DBMS.

--
Jonathan Leffler #include
Guardian of DBD::Informix - v2008.0229 - http://dbi.perl.org
"Blessed are we who can laugh at ourselves, for we shall never cease to be
amused."



bong@xxxxxxxxxxx

Relevant Pages

  • Re: Inserting LOB into DB2 in pieces
    ... Is there a way to store the uploaded file in pieces, ... is bound to a LOB column. ... a separate process from the DBMS. ...
    (perl.dbi.users)
  • Inserting LOB into DB2 in pieces
    ... I'm writing an Apache::ASP program to upload a file and store it in a LOB column in DB2. ... Is there a way to store the uploaded file in pieces, ...
    (perl.dbi.users)