How to Retrieve Table Properties in a ProgramLast reviewed: April 30, 1996Article ID: Q130604 |
The information in this article applies to:
SUMMARYVisual FoxPro introduces new table properties (triggers, validation rules, and comments) that are available to fields in tables that belong to databases. This article describes how to look up these table properties by using a program.
MORE INFORMATIONThe new properties are available only if the table belongs to a database. You can use the DISPLAY DATABASE and LIST DATABASE commands to view, list to a file, or print all the table properties. The following examples apply only to the case where you want a program to retrieve the table properties to store in variables or for some other purpose.
Validation RuleUse the AFIELDS() or DBGETPROP() function to obtain the value of the Validation Rule table property. AFIELDS() places information about the table structure into an array. The syntax for AFIELDS() is:
cResult=AFIELDS(ArrayName[,TableName | WorkArea])Parameters:
cResult=AFIELDS(myarray,mydata) ?myarray(1,10)DBGETPROP() retrieves several table properties. The following example shows how to return the Validation Rule of a table by using the DBGETPROP() function:
cResult=DBGETPROP('mydata', 'TABLE', 'RuleExpression')In this example:
Validation TextUse the AFIELDS() or DBGETPROP() function to obtain the value for the Validation Text table property. AFIELDS() creates a multi-dimensional array, the Validation Text is stored in column 11. The following example retrieves the Validation Text for a table named MYDATA.DBF:
cResult=AFIELDS(myarray,mydata) ?myarray(1,11)The following example shows how to return the Validation Text of a table by using the DBGETPROP() function:
cResult=DBGETPROP('mydata', 'TABLE', 'RuleText') Insert TriggerUse the DBGETPROP() function to obtain the Insert Trigger, as in this example:
cResult=DBGETPROP('mydata', 'TABLE', 'InsertTrigger') Update TriggerUse the DBGETPROP() function to obtain the Update Trigger, as in this example:
cResult=DBGETPROP('mydata', 'TABLE', 'UpdateTrigger') Delete TriggerUse the DBGETPROP() function to obtain the Delete Trigger, as in this example:
cResult=DBGETPROP('mydata', 'TABLE', 'DeleteTrigger') Table CommentsUse the DBGETPROP() function to obtain the Table Comments:
cResult=DBGETPROP('mydata', 'TABLE', 'Comment') Primary KeyUse the DBGETPROP() function to obtain the tag name of a Primary key, as in this example:
cResult=DBGETPROP('mydata', 'TABLE', 'PrimaryKey') PathUse the DBGETPROP() or DBF() function to obtain the path to the table. The following example shows how to return the path of a table by using the DBGETPROP() function:
cResult=DBGETPROP('mydata', 'TABLE', 'Path')To obtain the path to a table by using the DBF() function, SET FULLPATH must be used, as in this example:
SET FULLPATH ON cResult=DBF('mydata') |
Additional reference words: 3.00 VFoxWin
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |