Chapter 3 Managing Files

Modifying Table Structure
Table structure are need to be modified like existing field characteristics, field size and so on.  Such operations can be done:-

Modify Structure or by
Modi Stru

Copying Files
COPY TO command is used to copy selected fields from one table to another table.
Use Fees
Copy to Fees99

Copy to command allows to copy a certain portion of currently selected table file depending on specified condition.
Copy to Fees99 fields RollNo, Fees_paid
Copy to Fess99 Fees_paid>2500

Copying files can be done by specifying file Extensions.
Copy file Marks.DBF to NewMark.DBF

RENAMING
Renaming files can be done using RENAME command.
Rename Marks.DBF to Stu_Ref.DBF.

Erasing File
To erase a file DELETE File command is used with the File Extensions.  Syntax:
Delete File<File Name>
Delete File Fees.DBF.
Delete File Student.DBF

Multiple File Handling
To open multiple files at a time is possible in FoxPro.  FoxPro allows to open more than one table at a time.  Up to 225 files can be opened at a time.  Each open file (Table) is held in a separate Work Area.

Work Area
A work area is simply a place where FoxPro keeps track of a single table and all related information.  By default work areas are numbered from 1 through 225.  After a select command is used to choose a work area, desired table is opened.  For Example:
Select 1
Use Student
Select 2
Use Marks
Any table can be made active by selecting that work area.

Setting Relationship
Relationship can be established between tables with the SET RELATION command. Which draws the relationship between a key field which is common to two or more tables.  The table in second work area must be indexed on field which is used to link the files, before SET RELATION command is used.  For Example:

Select 1
Use Student
Index on RollNo tag StuRoll

Select 2
Use Marks
Index On RollNo tag MkRoll
Set relation to RollNo into Student

Go 3
Display FName, City, RollNo

SET RELATION command is not limited to two tables.  Number of tables can be linked as long as a common key fields is exists between two tables.

When multiple tables are required to be used, fields from different tables can be specified within a command.  For Example:
Go top
List RollNo, Mark1, Mark2, Mark3, Student.FName, Student.City

No comments:

Post a Comment