Other Topics
Saving
Select Save from the File menu or click the Save button on the toolbar to save the currently open table definition. If a table has data in it and you have changed its structure or indexes, you will see the Restructure options for saving panel with reindexing and restructuring options. If the table contains no data, the new definition will simply be saved on top of the previous one.
Restructure Options for Saving
If you have made changes to a table’s structure, such as changing the length of a column, deleting a column, or changing a column's type, the table data will need restructuring, and a notification in the dialog box will inform you so. There is a checkbox for forcing the table to restructure even if no such changes were made, and there is a checkbox for creating a new .DEF file for the table.
Use Temporary File or Attempt In Place
You may choose restructuring to a temporary file or restructuring in place (in case you do not have enough room to restructure to a temporary file). Restructuring in place should only be done if you have a copy of the table or are confident that the process will complete without interruption, since any interruption to the process will render the table completely unusable by any version of DataFlex. Restructuring to a temporary file is much safer and ensures that a workable copy of the table exists at all times, even in the event of a power outage. Database Builder first renames the existing table, then restructures it into a table with the old name.
There are some instances where restructuring cannot, or definitely should not, be done in place:
- Turning on compression causes the creation of a
.VLDfile and a temporary file for the.DATfile. Restructuring in place is always ignored in this case. - If you are converting a 2.3b table to 3.0 format and reducing the row length, then two passes are made. First the header is converted, then the rows.
- Restructuring a compressed table in place results in a much larger table than the original one, because of the way operating systems utilize blocks.
- If you added an index or changed the definition of an existing one, reindexing of the affected index(es) will be required, and a notification in the dialog box will inform you so.
When you have made any required choices concerning restructuring, press F2 to start the process. Alternatively, press Esc to cancel the process. Messages will remain on screen afterwards to tell you the results of the restructure and/or reindex. When you exit, you will be returned to the menu bar if you were saving from the Save choice, or you will exit Database Builder if you were saving from the Exit choice.
Closing
To close a table, select Close from the File menu or click the close box of the table’s panel. If you have made changes to the table definition in the current session, you will be asked to confirm whether you want to save those changes.
Close All
Select Close All from the File menu to close all open table definitions.
Loading DEF Files
Database Builder can automatically create a working file definition by loading the ASCII file with the name filename.DEF (created with the Output .DEF option).
To load a .DEF file, select Load DEF from the File menu.
Table Number
If no table is loaded, or you choose to create an additional table, this window displays the lowest unused number in your file list. You can enter another number.
File Name
Next, enter the directory file name for the new table, including a drive and path if you wish.
DEF File
This window displays, by default, whatever is in the previous window. Enter the name of the .DEF file to use as the definition for the new (or new version of the) table, including path, if desired.
Select OK to have the program build the new table. If there is already a table of the same name, you will be asked if you want to overwrite it. If the .DEF can't be found, you will see a message to that effect. If the operation was successful, the new table is created and opened, and you are put into the table-definition dialog.
Output Definition Files
Database Builder can generate an ASCII file containing information about columns and indexes of a table. There are two types of files you may generate: .FD files and .DEF files (meaning files with the same name as the table and the extension of .FD or .DEF).
To output definition files, select Output .DEF from the File menu.
Select the tables you wish to output definitions for, then click the Output DEF/FD button. You are next presented with the Select Destination panel.
You may check one or both file-type boxes, and check whether you wish output to a file (it will otherwise go to the printer). You may use .DEF files to create new files with the same definitions (then change those definitions if you wish), and you may also use them for reference and documentation purposes, since they are in plain ASCII text.
Output .DEF
The .DEF file stores information about the table itself and the length and type of columns, column names, offsets, and indexes.
DriverName defaults to DataFlex and can accept other supported table types such as ODBC.
The Transaction Type parameter has meaning for access to tables through data-dictionary objects. Any table your programs access through data dictionaries must have their Transaction Type set to client_atomic or server_atomic. Setting it to none will cause an error when your program attempts to save to or delete from the table. These two parameters can be set in File, Attributes.
Record Identity Index contains information to support automatic system updates (such as is available with ODBC). The parameters are the index number and, in parentheses, the table number and column number.
System File reflects whether the table has been designated a system table. If so, the maximum number of rows is set to 1.
Output .FD
The DataFlex compiler uses .FD files to read in the name and type of each column of any table you open in a program.
Below is an example of an .FD file:
#REPLACE FILE25 CUSTOMER
#REPLACE CUSTOMER.RECNUM |FN25,0
#REPLACE CUSTOMER.NUMBER |FN25,1
#REPLACE CUSTOMER.NAME |FS25,2
#REPLACE CUSTOMER.ADDRESS |FS25,3
#REPLACE CUSTOMER.CITY |FS25,4
#REPLACE CUSTOMER.STATE |FS25,5
#REPLACE CUSTOMER.ZIP |FS25,6
#REPLACE CUSTOMER.PHONE_NUMBER |FS25,7
#REPLACE CUSTOMER.FAX_NUMBER |FS25,8
#REPLACE CUSTOMER.EMAIL_ADDRESS |FS25,9
#REPLACE CUSTOMER.CREDIT_LIMIT |FN25,10
#REPLACE CUSTOMER.PURCHASES |FN25,11
#REPLACE CUSTOMER.BALANCE |FN25,12
#REPLACE CUSTOMER.COMMENTS |FS25,13