Sunday, December 14, 2008

Firebird

One of the programs which I have developed for my occupational psychologist needs to transfer relatively large amounts of data around the network, as it is retrieving pictures from a database. We have found that it is possible to work with this program only if the data resides on the same computer on which the program is running. This is not acceptable as we ideally want an administrator to update the 'clever' parts of the program from one computer, a secretary to enter new people's data from another computer, and people to sit the program's exams from other computers. Eventually we even want the program to work as standalone (I managed to convert our other programs to standalone by using stringtables).

Enter Firebird. This is a sql database manager (RDBMS) which can run as an embedded application, and so theoretically solve all our problems.

Downloading and installing the RDBMS was very easy, and within minutes I had set up a simple database, with the goal of accessing this from a Delphi program. Then the fun began.

I tried different sets of components before settling on the dbExpress set (to be honest, I could have stayed with the InterBase component set which comes with Delphi 7, as this seems to be equivalent). Unfortunately I couldn't find much documentation, and whatever sample programs I did find worked in such a way that all the data from a table was downloaded whenever a query was opened. As this seemed to be the complete opposite of what is needed from a db program (download as little as possible), these samples weren't much use.

I managed to cobble a program together which actually worked, but this required a fair amount of coding (especially coding insert and update queries) as opposed to letting the components do their work automagically. There had to be a better way, I kept telling myself.

Eventually I stumbled on some code by Dr Bob (not the Muppet), which at least showed the way to writing the code which I wanted. There was still a certain amount of work which I had to do myself, but eventually I nailed it. Now I have working code which can either insert a new record into a table, or take an existing record and edit it, posting the results back to the table.

Now this task is done, porting my application from BDE to Firefox will be fairly easy, if tiresome.

No comments: