DF_FILE_RESTRUCTURE
See Also: Get_Attribute, Set_Attribute, DF_FILE_RESTRUCTURE_INT_ONLY
The status of the restructure on a table.
Level
Table
Supported by
All Drivers
Type
Flag of bits, temporary
Access
Read Only
Values
DF_NO_RESTRUCTUREDF_RESTRUCTURE_FILEDF_RESTRUCTURE_INDEXDF_RESTRUCTURE_BOTH
Syntax
Use cli.pkg
Get_Attribute DF_FILE_RESTRUCTURE of {tableNumber} to {IntegerVariable}
Remarks
When data-table-structure maintenance is performed, it may be necessary to restructure the data to fit the new structure of the table. The DF_FILE_RESTRUCTURE attribute will be:
DF_NO_RESTRUCTUREif no restructuring is needed,DF_RESTRUCTURE_FILEif data restructure is needed,DF_RESTRUCTURE_INDEXif the indexes need to be rebuilt, orDF_RESTRUCTURE_BOTHif both data restructure and index rebuild are needed.
DF_RESTRUCTURE_BOTH combines DF_RESTRUCTURE_FILE and DF_RESTRUCTURE_INDEX.
This attribute is often used to inform the user of the actions that are going to take place.
Example
The sample function below shows a message box in which the user is informed about the action. The procedure calls the function to determine if the save should proceed.
Function Proceed Handle hTable Returns Boolean
Integer iRestruct iAnswer
String sMessage sTitle sTable
Get_Attribute DF_FILE_RESTRUCTURE Of hTable To iRestruct
Get_Attribute DF_FILE_PHYSICAL_NAME Of hTable To sTable
Move ("Saving structure change to" * sTable) To sTitle
If (iRestruct = DF_NO_RESTRUCTURE) ;
Move ("No restructure operation required.\n") To sMessage
Else Begin
Move "" To sMessage
If (iRestruct iAnd DF_RESTRUCTURE_FILE) ;
Move (sMessage - "Table must be restructured.\n") To sMessage
If (iRestruct iAnd DF_RESTRUCTURE_INDEX) ;
Move (sMessage - "Indices must be rebuilt.\n") To sMessage
End
Move (sMessage - "Do you want to proceed?") To sMessage
Get YesNo_Box sMessage sTitle MB_DEFBUTTON1 To iAnswer
Function_Return (iAnswer = MBR_YES)
End_Function
Procedure RestructTest
Handle hStruct
Integer iColumn iIndex
Boolean bSave
//*** Add a column
Open Customer Mode DF_EXCLUSIVE
Move Customer.File_Number To hStruct
Structure_Start hStruct
Move 0 To iColumn
Create_Field hStruct At iColumn
Set_Attribute DF_FIELD_NAME Of hStruct iColumn To "NewColumn"
Set_Attribute DF_FIELD_TYPE Of hStruct iColumn To DF_ASCII
Set_Attribute DF_FIELD_LENGTH Of hStruct iColumn To 20
Get Proceed hStruct To bSave
If (bSave) ;
Structure_End hStruct
Else ;
Structure_Abort hStruct
//*** Add an Index (City, Customer_Number)
Open Customer Mode DF_EXCLUSIVE
Move Customer.File_Number To hStruct
Structure_Start hStruct
Move 0 To iIndex
Create_Index hStruct At iIndex
Set_Attribute DF_INDEX_NUMBER_SEGMENTS Of hStruct iIndex To 2
Set_Attribute DF_INDEX_SEGMENT_FIELD Of hStruct iIndex 1 To 4
Set_Attribute DF_INDEX_SEGMENT_FIELD Of hStruct iIndex 2 To 1
Get Proceed hStruct To bSave
If (bSave) ;
Structure_End hStruct
Else ;
Structure_Abort hStruct
//*** Add a column and an index (State, Customer_Number)
Open Customer Mode DF_EXCLUSIVE
Move Customer.File_Number To hStruct
Structure_Start hStruct
Move 0 To iColumn
Create_Field hStruct At iColumn
Set_Attribute DF_FIELD_NAME Of hStruct iColumn To "NewColumn2"
Set_Attribute DF_FIELD_TYPE Of hStruct iColumn To DF_ASCII
Set_Attribute DF_FIELD_LENGTH Of hStruct iColumn To 20
Move 0 To iIndex
Create_Index hStruct At iIndex
Set_Attribute DF_INDEX_NUMBER_SEGMENTS Of hStruct iIndex To 2
Set_Attribute DF_INDEX_SEGMENT_FIELD Of hStruct iIndex 1 To 5
Set_Attribute DF_INDEX_SEGMENT_FIELD Of hStruct iIndex 2 To 1
Get Proceed hStruct To bSave
If (bSave) ;
Structure_End hStruct
Else ;
Structure_Abort hStruct
End_Procedure