Moving BLOB fields from one SQL Database into InterBase database using FireDAC
In general, there is no difference between moving non-BLOB and BLOB fields into an InterBase database, so any technique may be used, depending on your needs:
1. One technique is to use two regular TFDQuery components; one TFDQuery will read with SELECT, and another will write with INSERT / UPDATE. The process is as follows:
1) Read the data from a FireDAC query into a RAD Studio, Delphi or C++ Builder application from a SQL Database.
2) Push the data via a FireDAC connection into an InterBase database.
This sample shows the support for BLOB (Binary Large Object) streaming in FireDAC using the CreateBlobStream method of TFDQuery.
2. Another technique is to use FireDAC TFDBatchMove. See some FireDAC TFDBatchMove examples here: http://docwiki.embarcadero.com/CodeExamples/Tokyo/en/FireDAC.TFDBatchMove_Sample
3. A third technique is to use "real BLOB streaming" that is optimized for BLOB values and two TFDQuery components like in the first option above. Real BLOB streaming is useful when BLOB values are large. For examples on how to use FireDAC Real Blob Streaming (to read / write blobs), see Support for Blob Streaming in FireDAC.
4. For loading Images into an InterBase database, I wrote in this How to insert an InterBase blob with RAD Studio using FireDAC and LoadFromFile post, describing how you can use FireDAC and load the Images into an InterBase database at design time using the FDQuery1IMAGE_FIELD_NAME technique:
And you should also be able to do the same to load .movs, .pdfs, audio files, etc.
Some have commented that using the technique in 4, you need to create persistent fields, but you may also use dynamic fields to do the same, for example, by using this sample C++ Builder code:
In RAD Studio 10.2 Tokyo, TDBImage is capable of handling not only BMP but also JPG, PNG, etc.
For example, for TImage, you can use this sample code:
TStream * str = FDQuery1->CreateBlobStream(FDQuery1->FieldByName("Image_Field_Name"), bmRead);
TBitmap * bmp = new TBitmap();
Another Code Example on how to use TDBImage can be found here .
6. Lastly, as mentioned in 3, for effective BLOB reading / writing you should consider using FireDAC Real Blob Streaming as described here:
Hope this helps and gives you some ideas on how you can move BLOB fields from one SQL Database into InterBase database using FireDAC.
Please login first in order for you to submit comments