4D v13.4Editing records |
||
|
4D v13.4
Editing records
Editing records
This section presents the major operations you perform when working with records in your database:
After you create a database in the Design environment, you can begin to work with your records (entry, modification, deletion, etc.). These operations are usually carried out in the Application environment via a custom interface. 4D also provides you with the possibility of entering, modifying or deleting records via the Design environment. This means that you can carry out certain basic tasks and test the data of your application. After adding records to your database, you will usually need to modify the information. If you need to modify one or more records, you can use one of the record selection methods available in 4D to display them (see the Searching records chapter). You can then modify them using either the input or output form. Sometimes you need to make exactly the same change to a group of records in a table. This is called a global update. In 4D, you can update the current selection of a table automatically — without having to make the change to each record individually. You may also find that you need to delete one or more records. You can delete a record if you discover it is outdated or irrelevant. If the record is needed but the values stored in it are no longer correct, you should modify the record rather than deleting it. You can delete the current record from an input form or you can delete a subset of records in the current selection using the output form. You can add records using either an input or output form. In the Application environment, records may be added via the “Add Subrecord” standard action (adds a record to a list) or via the ADD RECORD and CREATE RECORD commands. In the Design environment, 4D provides by default several adding functions for both input and output forms.
You can also add records directly in the Output form. Keep in mind that in this case you cannot enter data into variables, fields from other tables, or subforms.
You modify records when you need to update information or when you discover that the information originally entered is incorrect. Before modifying a group of records, select the records to modify as the current selection. You can search to select records for modification or select the records after highlighting them in the output form. You can modify records using either the input or output form. The output form is convenient for modifying a group of records because several records are displayed at the same time. However, the output form typically does not include all the fields of the input form and may not duplicate the input form’s data entry controls. In the Application environment, records may be modified via the “Edit Subrecord” standard action (modifying a record in list form) or via the MODIFY RECORD command. In the Design environment, 4D provides several modifying functions.
You can modify the fields displayed directly in the output form. Keep in mind that in this case you cannot enter data into variables, fields from other tables, or subforms.
You do a global update when you want to make a specific change to a group of records. You perform a global update to automate changes to a group of records that would otherwise be tedious and time-consuming. For example, you would perform a global update if you wanted to do the following:
The global update is done by “applying” a formula to the current selection of records. In other words, the formula is used to make the change to each record in the current selection. Here are some example formulas and explanations of the functions they perform:
The ability to include user-written functions when carrying out global updates is a powerful feature of 4D. Formulas can contain 4D language functions as well as project methods (declared “usable” in the forms by the developer). For security reasons, access to project methods in the formulas is restricted (see DOM Get XML document ref). You cannot write formulas that are longer than a single logical line, in other words, you cannot hit the Carriage return and enter a second line. However, methods that are declared usable in the formula editor can, of course, consist of several lines. To carry out a global update, you can use the Formula editor to write the formula which will then be applied to each record of the current selection. To do this, you choose the Apply Formula... command in the Records menu and then write your formula. You can also load a formula that was previously saved on disk as a file (extension .4fr). For more information, refer to the Formula editor chapter. In the Application environment, you can execute an update formula directly via the EXECUTE FORMULA command or display the formula editor via the EDIT FORMULA command. You may want to delete a record that is outdated or no longer necessary. If the record is needed but the values stored in the record are incorrect, you should modify the record rather than delete it. You can delete records in two ways:
In Application mode, the deletion of records is carried out via the “Delete Record” or “Delete Subrecord” (deletion in list) standard actions or via the DELETE RECORD or DELETE SELECTION commands. In the Design environment, you can also use the Clear command of the Edit menu as well as the deletion keys. Warning: Deleting records is permanent and can only be undone by restoring a database backup. When you delete records, 4D displays a dialog box asking you to confirm the deletion. Deleting records from the input form lets you verify the contents of each record before you delete it.
Using the output form, you can delete several records in one operation. The records to be deleted must be highlighted in the output form.
You cannot delete locked records. Records are locked when they are being used by another process. For instance, if a process opens a record for modification, 4D locks that record so that other processes cannot modify it. Note for 4D Server: Records are also locked when they are being used by another user. Before deleting records, you create a selection of the records you want to delete. If your selection includes any locked records, the deletion will proceed but the locked records will not be deleted and will remain in the current selection after the deletion. You must wait until these records are unlocked (i.e., no longer being used) to delete them. The commands of the Record Locking theme can be used to manage this type of scenario. The current selection may be altered by records being deleted in another process. For example, while you are working in your database, you might start another process that deletes certain records from a table. The records deleted in that process are permanently removed from the table. However, the records you see while working with the database may not reflect those changes to the table until a new selection of records is created. To illustrate this point, suppose that a table contains fifty records and that all of the records are in the current selection. At this point, the title bar of the output form says that “50 of 50” records are selected. If one of the records is deleted in another process, the title bar changes to say that “50 of 49” records are selected. There now appears to be more records in the current selection than in the table! The title bar will be updated when you change your current selection. If you attempt to modify or delete the deleted record, a dialog box will appear saying that the record has been deleted. Note for 4D Server: Records deleted by another user have the same effect on the current selection. The records are deleted from the table, but not from the current selection. Thus, the current selection may appear to contain more records than actually exist in the table. |
PROPERTIES
Product: 4D |