select blob from mysql using firedac

0

Hello,

I discoverd a big problem with Delphi 10.2.1 and firedac. A simple select on a blob field from MySQL failes.

I.E. "SELECT blob FROM table"

 

Regards

Hans

 

  • Accepted Answer

    Sunday, October 15 2017, 03:33 AM - #Permalink
    0

    The issue was caused by the MySQL connector (wrong version) and not by fireDAC.

    Sorry for the trouble caused.

    Hans

     

    The reply is currently minimized Show
  • Responses (3)
    • Accepted Answer

      Monday, October 16 2017, 02:09 AM - #Permalink
      0

      Good,
      At least you nailed it! 
      Document it for yourself for future implementations :-)
      Happy coding!
      Steve

      The reply is currently minimized Show
    • Accepted Answer

      Friday, October 13 2017, 04:16 AM - #Permalink
      0

      Thanks Steve,

      The issue happens before.

      fdQuery.sql.Text := 'SELECT contentObject from pdf_table';

      fdQuery.open; << fails with MySQL

      I tried the same with SQLite and this seems to be working fine. So this is maybe a MySQL(connector) problem.

       

      The reply is currently minimized Show
    • Accepted Answer

      Friday, October 13 2017, 01:51 AM - #Permalink
      0

       

      What I do with SQLite, I think it should work with any DB.
      I store PDFs into a BLOB field. Here is how I retrieve one and save it to disk

      var

        Form1: TForm1;

        BlobStream: TStream;

      ...

       

      begin

        // Save the PDF file to c:\

        BlobStream := fdQuery.CreateBlobStream(fdQuery.FieldByName('contentObject'), bmRead);

        try

          BlobStream.Seek(0, soFromBeginning);

          with TFileStream.Create('c:\\contract.pdf', fmCreate) do

            try

              CopyFrom(BlobStream, BlobStream.Size)

            finally

              Free

            end;

       

        finally

          BlobStream.Free

        end;

       

      end;

      end.

       

       

      The reply is currently minimized Show
    Your Reply

    Please login to post a reply