changing key size
Bill Vermillion
fp at wjv.com
Mon Aug 30 18:23:32 PDT 2004
On Mon, Aug 30 15:35 , Dave Andersen gie sprachen "Vyizdur zomen
emororz izaziz zander izorziz", and continued with:
> Hi, I?m new to filePro. We have a customer who wants to merge
> 4 filePro databases together (identical schemas). There is
> a problem with the key fields though, because each database
> started at 1. So we want to prepend a value to the keys in each
> table to make them unique. So record 10000 would become 110000
> at location 1, and at location 2 10000 would become 210000.
> It looks like the first task is to change the schema for each
> table and change ?5 *? to ?7 *? (widen the field).
> At first our customer asked us to write a script to edit the
> table/Key file directly. This seems like a bad idea because the
> file is not plain text and I?m pretty sure we would corrupt it.
He was probably not a programmers.
When I've had to consolidate files for various reasons, I added new
fields temporarily.
In this case besides wideining your key field I'd add a new field
to each file. That field will be what will eventually be the new
key field.
Then you can run process on the key field in each file and store
the results in this new field. This way you can be sure that
everything is correct and you have not taken the chance of ruining
and existing data and having to go back to backups.
Then if each file is fine unto itself, you could copy that new key
field back to the original field and the merge the other files into
one.
> So I guess we have two options: 1) figure out filePro
> processing or 2) export to csv, process the table with a
> script, re-import.
I think doing the work in FP would be far easier. Write a process
that takes the key field, and just prepends the numbers you wish
and write that to the new field you created.
This way nothing can happen to any of the data. Exporting and
editing from my POV would be about the hardest way to do it.
Use the Power of Filepro Luke.
If each file has a value than doesnt exceed some value, you could
round up to the nearest even value.
If the first file's key field never goes higher than 10,000, then
in the FP processing for the second file you would add 10,000 to
that field.
If the new field was 150, and the first key field was 1,
then it would be as simple as 150 = 1 + "10000"
That is assuming your keys are numeric fields.
For the next file you would add 20000 and so forth. It will take
about as long as processing each record. On a fast machine
it could be about a minute for each file.
Bill
--
Bill Vermillion - bv @ wjv . com
More information about the Filepro-list
mailing list