LO Base: Set value of LONGVARBINARY column from file through SQL?

asked 2016-08-08 22:30:05 +0200

Olav gravatar image

Dear LO Base gurus,

I am trying to create a simple database with some tables and forms. Setting it up wasn’t difficult but I am stuck where I am trying to load some existing data into my tables.

So is there a standard way in Base to insert or update a LONGVARBINARY column from a binary file through an SQL/DML query?

Ideally what I am after would be some equivalent of this syntax in MySQL:

insert into person (id, photo) values (1, load_file('photo.jpg'));

or

update person set photo = load_file('photo.jpg') where id = 1;

or even

update person set photo = load_file('photo_'+id+'.jpg');

If there is no function corresponding to load_file() in Base I suppose I am going to have to use a macro. However I am reasonably well versed in databases but I am afraid I haven’t a clue on where to start with VBA programming. I would appreciate any pointers here.

Because of my googling so far I am aware that the common wisdom regarding pictures in Base tables is to link them by putting their filenames into text columns, not store them into blobs. However I have reasons for wanting to try this approach. The main one being that it frees the user of the responsibility of managing a folder full of pictures. So if I can give my user just a single .odb file that they can open and work with, that would avoid some potential headaches/mishaps.

Thank you.

edit retag flag offensive close merge delete