Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

handling tables with 'occurs'

Status
Not open for further replies.

Howard2002

Programmer
Aug 2, 2002
12
US
I have a table that has several fields (name,ssn,wage etc...) that occurs 5 times(as it was written in COBOL). My question how do you code in VFP for the occurrs without having to create multiple tables with the same fields. any help would be greatly appericated.
 
do you have 5 tables of the same name?

if you are trying to reference the same table five times.
LOOK in the help file for USE command, it has optons for opening the same table multiable times. Attitude is Everything
 
If we can assume that all these duplicated fields are somehow related to the rest of the fields in the record, then I see two approaches.
1) Keep them all in the same table, and you'll need to change the field names for all the duplicates. : e.g.

...
name1
ssn1
wage1
...
name2
ssn2
wage2
...
...
name5
ssn5
wage5

Then big problem with this is that you'll need to use a lot of code and/or macro expansion (&'s) to access these.

2) You could split the table into 2, where the first holds the not repeating fields (and each record has a primary key), and the second table, would hold the related key, a "section" value (1-5), and then the fields:
name
ssn
wage
...

This would make it easy to code for searching, and reporting with a simple Join in SQL.

Rick

 
I have split the occurs from the main table. they are defined (with a key field in both)
name1
ssn1
wage1
name2
ssn2
wage2 etc...
My question is how do call the ssn1 etc... to a listbox on the form
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top