Main Table Processing

For each procedure body in your program that accesses the database, you must select a main table. You can determine whether the procedure may add, delete or amend records in the main table. The Main Table dialog looks like this:

Table name

Enter the name of the main table you want to process. Press <Ctrl+P> for a menu of tables in the database.

Identifying role

Some programs need more than one copy of a table. When this is true, each copy must have a different role. (For example, in the TIME database the EMPLOYEE table is one of its own parents, because each employee has a manager who is also an employee. The employee data entry program needs two copies of the table, so that each employee's manager can be read without overwriting the base employee record.) Press <Ctrl+P> for a menu of other copies of the table.

Access mode

Select from the menu the mode in which the database is accessed:

1 Already fetched

Select this option when the record to be processed has already been read from the database or has been set up in an earlier procedure.

2 Batch (Automatic)

Select this option to process a group of records from the table or all the records in the table. With this option a record is read before any other processing takes place. It should normally be used only in repeated procedures.

3 Normal

Select this option when the record to be processed is selected during the procedure, for example, when the user enters the key.

4 Line (Auto & Normal)

Select this option to combine batch and normal access. It provides an inelegant way of writing programs for breakdown line processing and should be used only in repeated procedures. Your program will be better if you use Window or Cleared window access.

5 Window

This option is useful for breakdown line processing. Select it if you want to offer the user a menu of existing records through which to scroll (perhaps with an Add new record option). This differs from Normal and Multiple choice access in that the user does not enter the key first. The menu remains fixed to the screen throughout the procedure.

You may put a menu of actions in the window, so that the use may select a record with the cursor and an action with the mouse or by typing a mnemonic or using a function key. To do this, in the choice map for the window add field 101 where you want the menu displayed and create a function key area map as a menu with fields for each possible action. In Interactive-type procedures the possible actions are 1 Amend, 2 Delete and 8 Exit window. In Combined menu/entry-type procedures, Option 1 is assumed to be Amend and option 2 Delete, if the procedure body does this processing. You may set up other processing options on other numbers. If a hot key function is installed, F1 is assumed to be Amend, F2 Delete and F8 Exit Window. You may use other hot keys for other processing options.

6 Cleared window

This is the same as Window access, except that the menu of records disappears from the screen after a choice has been made.

7 Set up mode

Use this mode if you want to set up fields in a table which has not yet been read from the database and which you do not want to read now. It is useful when you want to initialise key fields prior to batch access in later procedures.

8 Preview window

Use this option if you want to fill a window with a list of records without the user having to select one of them. There are three types of preview window selected from a sub-menu:

1 Predisplay window – Use this option to fill in a window without any user intervention.

2 Scrolling preview – This is like an ordinary window, but the cursor keys all scroll the window and the user cannot make a selection.

3 Cleared preview – This is like an ordinary cleared window, but the cursor keys all scroll the window and the user cannot make a selection.

9 Run time sort

Select this option, available only in batch and print procedures, to process a group of records from the table or all the records in the table where there is no suitable index allowing the records to be processed in the right order. With this option all the records are read and sorted before any other processing takes place. This option should be used only in repeated procedures. You will be asked to specify the remaining details on this screen as though batch access had been selected – this allows you to select the most efficient index for your intended sort fields. In field processing, you should set the Sort? Option to the appropriate value for the field on which you wish to sort. You may sort on any fields, including calculated fields and fields from other tables. Note that while you may sort and process records in one procedure, because of the way in which PROGRUN works, execution is usually faster if separate procedures are used for sorting and processing.

10 Grid

This option is useful for breakdown line processing. Select it if you want to offer the user a menu of existing records through which to scroll. It differs from Window access in that there is no record selection phase. Data entry can take place in any of the lines in the window.

Typically a grid should have a function key area map containing an OK button as field 1 and a Cancel button numbered as field 2. The choice list map should have a field numbered 101 to position the function key area map. At run time, moving the cursor up from the first record or down from the last record takes it on to the buttons.

A grid procedure should normally secure changes and can only be used in a program which enables the private database.

Batch/preview type

Select the type of batch or preview access from the menu:

First and onwards

Select this option to process all the records in the table. If parent records were selected, all the selected records are processed, starting with the first record.

Equal and onwards

Select this option to process all the selected records, starting from a specified record.

Equal and backwards

Select this option to process all the selected records, starting from a specified record and working backwards.

Last and backwards

Select this option to process all the records in the table, starting with the last and working backwards. If parent records were selected, all the selected records are processed, starting with the last record.

The "backwards" methods of scanning through a table may be considerably slower than the "onwards" methods.

Update main table

Select this option if the record being processed is posted to the database (insert or update).

If you find this option is disabled you need to change your answers to some earlier questions as described here.

Condition to update

You can impose a condition which must be satisfied for this table to be updated. Select the required action from the Formula Editing menu.

Process existing records

Always enable this option unless you are updating this table and wish to prevent the user from amending records that are already on the database.

Allow new record

Enable this option if the user is allowed to add new records to the database.

New record dialog

Use this option to set up the dialog that will inform the user that he is processing a new record and asking him to confirm his actions. This dialog is optional when using Exact match search. You can use either a Yes/No question or a menu (if you generate the message automatically it will use the format determined by your answer to the Ask questions with menus option in the Program Summary). Option 1 means Add this record, option 2 means Scan/choose and option 8 Rekey. Option 2 is meaningless in Exact match searches. Select the required action from the Message Assignment menu.

Auto-increment Table

This field, and the next two are only relevant to procedures that add records in the main table to the database. For a detailed discussion of what auto-incrementing is and how to use it, refer to Auto-Increment.

Search method

Select the required record search method from the menu:

1 Exact match

This seeks a record which matches the key supplied by the user exactly

2 Scan if no match

This seeks a matching record, but if none is found it prompts the user with other records in the table, one by one, allowing him to scan forwards or backwards at will.

3 Always offer scan

This is similar to the previous option, but it always allows the user to scan, even if a matching record is found.

4 Next match This looks for a matching record, but if none is found selects the next record.
5 Previous match

This looks for a matching record, but if none is found selects the previous record.

6 Multiple choice

This looks for a matching record, but if none is found allows the user to select from a scrolling display of available records.

Search index

Enter the index to be used. Press <Ctrl+P> for a menu of indexes for this table.

Search depth

This is the number of keys which must match on any scans. Enter null (the default) if you want the Program Compiler to set the search depth to an appropriate value automatically.

Message if no record found

You may arrange for a message to appear when a search fails to find a matching record. Normal practice is to produce a separate message for each table that the program accesses. Select the required action from the Message Assignment menu .

Message when record found

You may arrange for a message to appear when a matching record is found. Normally the message is required for the main table and for other tables where there should not be a matching record. Select the required action from the Message Assignment menu.

Record scan dialog

If you have given the user the option of scanning through records, you must set up a message inviting him to accept the current record or select another one. You may choose to use the same message throughout the program or you may have different messages to suit different searches. Select the required action from the Message Assignment menu.

Map to display choice list

If you have given the user multiple-choice search, you must enter the number of the map that will display the list of multiple-choice items. You will be prompted with an unused map number if no map has yet been assigned to this part of the procedure. If a suitable map has already been set up, you may enter its number. Choose the map number and, if necessary, design the map via the Map Assignment menu .

Map to display item in list

If you have given the user multiple-choice search, you may enter the number of the map showing how a single item in the multiple-choice list should be displayed. You will be prompted with an unused map number if no map has yet been assigned to this part of the procedure. If a suitable map has already been set up, you may enter its number. If each item consists of only a single field, no such map is necessary. Choose the map number and, if necessary, design the map via the Map Assignment menu .

Map to attach choice list to

If you have given the user multiple-choice search, you may attach the map containing the choice list to another map. Enter the number of the map but ensure that it contains a field numbered (100 + the number of the choice list map).

Condition to access

Sometimes records should be read only under certain circumstances. For example, in the TIME database at least one employee must be at the top of the management hierarchy and so will not have his or her own manager. So the employee maintenance program makes this validation conditional. Select the required action from the Formula Editing menu .

Condition on record

You can impose a condition which must be satisfied by the record being processed. Such conditions may be used in a number of ways, for example, to filter the records to be handled by a batch process or offered when scanning or treat blank or null keys as requests for pop ups. Select the required action from the Formula Editing menu .

Apply to record not on db

Do you want to evaluate the condition on the table for new records? Normally disable this option, because the condition has to be evaluated before all the fields have been processed. However, if the condition involves only key fields, then it may be sensible to evaluate it.

If you enable it and you are using a scan or choose access method, the program will go straight into scans when the condition is not satisfied. This allows you to treat values such as Null and Space as prompt requests.

Record Locking

The final three questions in the table procesing dialogs relate to record locking. Before using record locking you are advised to read about Record Locking in QAB.

Lock existing record

Enable this option to lock the record which will be fetched at this point in the program.

Disallow locked record

Enable this option to abort processing of the procedure when a locked record is encountered in this program. (There is no point in enabling this option unless the system attempts to lock records in this table.)

Locked record retry question

If you wish to inform the user that the record to be processed has been locked by another user, select the appropriate action from the Message Assignment menu.