Subject Re: Coping a Binary File
From Mervyn Bick <invalid@invalid.invalid>
Date Tue, 27 Sep 2016 21:18:59 +0200
Newsgroups dbase.getting-started

On 27-Sep-16 8:50 PM, Forrest wrote:
> Forrest Wrote:
>
>> I am trying to copy a binary file (jpeg/bmp) (that meets criteria) from one table to another table.  I just can't figure it out.  Would someone help me?
>> Thanks, I would appreciate your help!
>> Forrest
> this is one of the things I have tried
>
>       dp = new query()
>       dp.database := d
>       dp.sql := [SELECT * from Deacons where name = Lnme ]
>       dp.active   := True
>
>       dp.rowset.Fields["Pict"].copyToFile("temp.jpg")
>       dp.active := false
>


Can you open temp.jpg and view it?  If so, you're half way there.  All
you need now an a query to write the .jpg into the target table.


       dt = new query()
       dt.database := d
       dt.sql := [SELECT * from Deacons where name = Lnme ]
       dt.active   := True
       dt.beginEdit()
       dt.rowset.fields["pict"].replaceFromFile('temp.jpg')
       dt.rowset.save()
       dt.active := false


There' a lot to be said for NOT using a binary field to hold images.
Instead, keep all the images together in a folder and store the path and
file name in a character field.

Mervyn.