4 Modifying the Database

Adding Entries

To add entries to a data set, use Query's ADD command. Its syntax is as follows:

ADD item list

If you specify a data set in item list, then Query will ask you for each data item in the data set. Entries are added to one data set at a time. For example, suppose that you want to add a new entry to the OPTION data set, which consists of four data items: ORDER_NO, OPTION_DESC, OPTION_PRICE, and OPTION_TYPE. The following shows the initial command executed to add the new entry; it also shows Query's prompts and the supplied responses:

   ADD OPTION

   OPTION
   ORDER_NO ?
   190
   OPTION_DESC ?
   Super Tire
   OPTION_PRICE ? 
   18
   OPTION_TYPE ?
   33

   OPTION
   ORDER_NO ?
   _
Query continues to prompt for new entries until the EXIT softkey is pressed. If you press EXIT before you have entered a value for every data in the list, then Query will not add any of the data item values to the database. For example:

   ADD OPTION

   OPTION
   ORDER_NO ?
   190
   OPTION_DESC ?
   Super Tire
   OPTION_PRICE ?
   18
   OPTION_TYPE ?
   33

   OPTION
   ORDER_NO ?
   200
   OPTION_DESC ?
   EXIT
   _
Order number 190 and its associated data items are added; however, order 200 is not added because the EXIT softkey was pressed before values for all four data items were supplied.

You can add specific data items in a data entry. The items not entered are given a null value (0 for numeric items and blank for alphabetic items). For example, the following shows a new addition to the OPTION data set. Notice that while the value "250" is supplied for ORDER_NO, nulls are supplied for the three remaining data items (a null is entered by simply pressing RETURN without typing in a value). The example also shows the result of executing FIND and LIST for this data entry:

   ADD OPTION

   OPTION
   ORDER_NO ?
   250
   OPTION_DESC ?

   OPTION_PRICE ?

   OPTION_TYPE ?

   OPTION
   ORDER_NO ?

   FIND OPTION FOR OPTION.ORDER_NO="250"
   **  1 entry found
   LIST

   OPTION          OPTION            OPTION             OPTION
   ORDER_NO        OPTION_DES        OPTION_PRICE       OPTION_TYPE
   ========        ==========        ============       ===========

   250                               0                  0
Later, the REPLACE command can be executed to give OPTION_DESC, OPTION_PRICE, and OPTION_TYPE values. Note that the REPLACE command does not operate on key items. Therefore, you should not enter a null value for a key item.

You can add entries to detail data sets and manual master data sets but entries are added to an automatic master data set for you. Further, if you are adding a new key item to a detail data set and that item is pointed to by a manual master, then you must first add the new key item value to the manual master.

If you make an error in entering a value, you can either press EXIT to terminate the command (if the error was not made on the last data item in the list), or use the REPLACE command to change the value.

Using Forms to Add Entries

If you frequently add the same data items to a database, you may find it more convenient to enter the data items into a standard form. A version of Query's ADD command makes it easy to display a form and then update the database with the data you type on the form:

ADD item list FROM "form name [ volume spec ]"

The item list is a list of specific data items or data sets to which new values will be added.

NOTE: When using a form to add entries to a database, the number of items in the item list must equal the number of input fields on the form. (Arrays require one field for each element.) The form input order must correspond to the order of the data items in the input list.

NOTE: If a data set name is supplied in the item list, Query expects an input field on the form for each data item in the data set; again, the form input field order must correspond to the data item order in the data set.

form name is the name of a form file, stored on the volume specified by volume spec. The form is created using the Forms software. For information on creating forms, refer to the Eloquence Forms Manual.

When the ADD command is used in this way, the specified form is displayed and the softkeys take a new definition. For example:

When the form is displayed, the cursor is placed in the first input field. Type in the correct information for that field; then press RETURN or TAB to move the cursor to the next input field. If you press RETURN at the last input field, Query prompts you to verify that the information typed in is correct. If it is, enter Y (yes). If not, enter N (no) and then re-enter any incorrect value. Once the form is correct and you press RETURN and Y, Query reads the form and adds the data item values to the database. Query then erases the entries, leaving a blank form so that you can continue to update the database. If you make a mistake and want to start over, press the CLEAR FORM softkey.

Pressing the ENTER softkey, at any input field, enters the data into the database without prompting you.

When you have made all the entries, press the EXIT softkey.


Eloquence Query Manual - 19 DEC 2002