changing key size
Laura Brody
laura at hvcomputer.com
Mon Aug 30 17:12:23 PDT 2004
On Mon, 30 Aug 2004 15:35:02 -0700, Dave Andersen <dave at PRIMUS.NET> wrote:
> 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).
>
Correct.
This can be done in "Define Files". Just get everyone out of the file,
make the change, then save changes. After the restructure is done,
go into "Index Maintnance" and rebuild the indexes that use the
expanded 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.
Yes, this would be a VERY BAD IDEA unless you know exactly what you
are doing.
>
> 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.
#2 would be taking the scenic route....
Your third option is to follow the directions that other filePro
people give you.
Your fourth option is to just hire someone, like me, to write the
prc tables then login to make the changes for you.
> Can you give me some ideas where to start? I’m confused on how to make a filePro script that would cycle through all the records.
>
You can write a processing-only report which would add the additional
number to the field, run it and all of the records would be changed.
The line in you prc table would be
then: 1 = "1" { 1
this would add a prefix of "1" to the contents of field 1 and place
it back into field 1.
After you did this on all 4 files (changing the "1" to "2", "3" and "4"
in each prc table for each report), you will need to merge the key
files together. This would involve one more prc-only report with
code that would get a free record, then copy a record from another
file into that record. Here is an example from my Help Files
product.
v1.0 \r COPYIN lookup \r - Copy a lookup file record to current record.
Example:
(Move a record from an archive file to the current file.)
if: ' Assume that the current file is "invoices".
' Get a free record to put the data.
then: lookup - r=free -n
if: not - ' No free records available.
then: end
then: lookup qual=invoices at 1999 k=ky i=a -nxp
if: not qual ' Record not found.
then: end
if: ' Copy the record from archive file
' to the current record, then delete it from the archive.
then: COPYIN qual; delete qual
See also: COPY, COPY_TO, LOOKUP
You would obviously have to do this three times to copy in
all of the records from the other 3 files.
>
> Is the $190 filePro book worth it?
I have no opinion since I don't have a copy. I have gotten
100% positive feedback from people who have purchased by
Quick Reference Guide and Help Files (and other products).
<http://www.hvcomputer.com/shopping/orderform.shtml#quickref>
--
Laura Brody, Publisher of the filePro Developer's Journal
+------------- Hudson Valley Computer Associates, Inc ----------+
| PO Box 859 120 Sixth Street http://www.hvcomputer.com |
| Verplanck, NY 10596-0859 Voice mail: (914) 739-5004 |
+------ PC repair locally, filePro programming globally --------+
More information about the Filepro-list
mailing list