Author: Tomas Rutkauskas
I am upgrading an application and need to add fields to a Paradox TTable database.
The application should inspect the existing database file structure and upgrade the
customers existing database if necessary.
First, open the files using a TTables exclusively, and check for fields. I was
adding fields so I used the following code:
1 with tblEmployer do2 begin3 open;
4 lFoundAddCalcMethod := FindField('RetireCalcMethod') <> nil;
5 lFoundRetireFundMethod := FindField('RetireFundMethod') <> nil;
If I was altering a field (for example, say I wanted to make a field change from
Integer to String), you could assing the result of FindField to a TField variable
and check it. Then I alter the table as needed:
8 ifnot lFoundAddCalcMethod then9 QryAddRetireCalcMethod.ExecSQL;
and the SQL part of the TQuery:
alter table "MAXXEMPL.DB"
add RetireCalcMethod character(2),
add RetireFundDollar Float,
add RetireFundPercent Float,
add LocalTaxMthd character(2);