Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: FireDAC and FetchBlobs with MySQL 5.5 and Delphi XE5



Permlink Replies: 3 - Last Post: Apr 17, 2015 1:42 AM Last Post By: Dmitry Arefiev
Frederic Wagner

Posts: 2
Registered: 5/7/15
FireDAC and FetchBlobs with MySQL 5.5 and Delphi XE5
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 7, 2015 8:42 AM
I try to obtain a stream of blob field stored in MySQL Database.
With Oracle and MSSQL, it works great but with MYSQL, it doesn't work.

I proceed like it's indicated in the documentation:
ms-help://embarcadero.rs_xe5/libraries/FireDAC.Comp.DataSet.TFDDataSet.FetchBlobs.html

FDQuery1.FetchOptions.Items := FDQuery1.FetchOptions.Items - [fiBlobs];
FDQuery1.Open;
....
FDQuery1.FetchBlobs;
oStr := FDQuery1.CreateBlobStream(FDQuery1.FieldByName('image'), bmRead);
try
// process image
finally
oStr.Free;
end; 


Does somebody succeed loading blob in mySQL database?
Thanks
Dmitry Arefiev

Posts: 1,406
Registered: 12/7/03
Re: FireDAC and FetchBlobs with MySQL 5.5 and Delphi XE5
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 7, 2015 9:16 AM   in response to: Frederic Wagner in response to: Frederic Wagner
Please provide the query text and the table DDL's used in this query.

--
With best regards,
Dmitry Arefiev / FireDAC Architect
Frederic Wagner

Posts: 2
Registered: 5/7/15
Re: FireDAC and FetchBlobs with MySQL 5.5 and Delphi XE5
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 16, 2015 5:54 AM   in response to: Dmitry Arefiev in response to: Dmitry Arefiev
Thanks Dmitry.

In fact, the program uses a TFDTable (instead of a FDQuery)

Before opening the table, we remove the fiBlobs option because data are loaded faster without the blobs.

FDTable1.FetchOptions.Items := FDTable1.FetchOptions.Items - [fiBlobs];

When we need the image, we load it with this code :
FDTable1.FetchBlobs;
oStr := FDTable1.CreateBlobStream(FDTable1.FieldByName('image'), bmRead);


If we don't remove the fiBlobs option, the image is well loaded by CreateBlobStream but opening the table is quite slow.
If we remove the the fiBlobs option, I noticed that FDTable1.FetchBlobs does nothing, so CreateBlobStream doesn't load the image

The image is saved in a blob field by this way :

CREATE TABLE Images ( 
PicNum int NOT NULL AUTO_INCREMENT PRIMARY KEY, 
image BLOB 
); 


We don't have the problem with Oracle or MSSQL database.

Dmitry Arefiev wrote:
Please provide the query text and the table DDL's used in this query.

--
With best regards,
Dmitry Arefiev / FireDAC Architect

Edited by: Frederic Wagner on Apr 16, 2015 5:56 AM
Dmitry Arefiev

Posts: 1,406
Registered: 12/7/03
Re: FireDAC and FetchBlobs with MySQL 5.5 and Delphi XE5
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 17, 2015 1:42 AM   in response to: Frederic Wagner in response to: Frederic Wagner
I cannot reproduce this issue on XE8 code base. Seems this issue was fixed.
Although I cannot find specific change in the change log. But in XE7 the BLOB
handling was refactored in many aspects.

Regarding MySQL and deferred BLOB fetching. Actually there is no sense to
use deferred BLOB fetching with MySQL, because MySQL transfers BLOB
values by value, not by reference like Oracle or SQL Server. So, excluding
fiBlobs from FetchOptions.Items should have no effect with MySQL.

Other note. Try to replace TFDTable with TFDQuery, if the performance is
important for you. TFDTable sends several SELECT statements behind the
scene. And all of them will fetch records with all fields, including BLOB's.
With TFDQuery you will explicitly control what and when to fetch.

--
With best regards,
Dmitry Arefiev / FireDAC Architect
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02