Page 1 of 1

Problem with upload file into PostgresDb

Posted: 12.10.2009, 09:06
by supercim
For upload a file into db i use this code

Code: Select all

  ot := TOpenDialog.Create(self);
  qry := TZQuery.Create(self);
  qry.Connection := db1;

  ot.Execute;

  qry.SQL.Add('insert into tbfile (filename,content) values (:filename,:content)');
  qry.ParamByName('filename').AsString := ExtractFileName(ot.FileName);
  qry.ParamByName('content').LoadFromFile(ot.FileName,ftBlob);
  qry.Open;
for a small file under 150 mb this right but for larger file i receive this error : EOutOfMemory with message 'out of memory'....
I also tried with loadfromstream and receive the same error....
I use Postgres 8.2.14 and zeos 5.5.0...

Thanks

Posted: 12.10.2009, 20:32
by seawolf
Have you tried updating zeos to lastest stable version (6.6.5)?

Posted: 13.10.2009, 07:48
by supercim
Yes, my last test was with zeos 6.6.5, Delphi 2007 and Postgres 8.4.1 ... the Stream of vcl working properly upon 1gb of allocation ... I also try lazarus and Zeos 6.6.5 and receive the same error...

Posted: 14.10.2009, 00:28
by mdaems
Seems like this may be a consequence of the way BLOB are loaded by zeoslib. Blob's are encoded and inserted into the sql statement, causing big strings to be used.
I'm afraid this is the only way we know to load blob's using libpq.dll.
So the one BLOB you have may be stored multiple times (encode/not encoded) in memory.

If you know how this can be done better, please tell us.

Mark

Posted: 14.10.2009, 21:19
by supercim
Thanks, when i found a solution i post the code bye
David