Modifying the Database

In this section:

You may use FSCAN to modify the database by adding, updating, and deleting segment instances.


Top of page

x
Adding New Segment Instances: The "I" Prefix

To add a new segment instance to the segment displayed on the screen, type the instance field values in the input area on the bottom of the screen. You can use the Tab key to jump from field to field. Then type I in the prefix area next to the new instance. When you press Enter, FSCAN adds the instance to the database, displaying it in proper sequence based on its key field values.

If the instance you are typing extends beyond the right margin of the screen, use the scrolling commands discussed in Scrolling the Screen. FSCAN adds the segment instance when you press Enter or enter any command except RIGHT, LEFT, RESET, ?, and QQUIT.

Note:



Example: Adding New Segment Instances

For example, suppose you want to add Fred Johnson to the EMPLOYEE database, and you want the new instance to become the current instance. Type his instance in the input area as shown below (note the I/ in the prefix area):

FSCAN FILE EMPLOYEEFOCUS A1     CHANGES :0
     EMP_ID     LAST_NAME  FIRST_NAME  HIRE_DATE  DEPARTMENT
     ------     ---------  ----------  ---------  ----------
==   117593129  JONES      DIANE       820501     MIS
==   119265415  SMITH      RICHARD     820104     PRODUCTION
==   119329144  BANNING    JOHN        820801     PRODUCTION
==   123764317  IRVING     JOAN        820104     PRODUCTION
==   126724188  ROMANS     ANTHONY     820701     PRODUCTION
==   219984371  MCCOY      JOHN        810701     MIS
==   326179357  BLACKWOOD  ROSEMARIE   820401     MIS
==   451123478  MCKNIGHT   ROGER       820202     PRODUCTION
==   543729165  GREENSPAN  MARY        820401     MIS
==   818692173  CROSS      BARBARA     811102     MIS
-----------------------------INPUT-------------------------------------
I/   123123123  johnson    fred        870507     mis
 
==>
                                                            MORE=>

When you press Enter, the screen appears as follows:

FSCAN FILE EMPLOYEEFOCUS A1          CHANGES :1
 
     EMP_ID     LAST_NAME  FIRST_NAME  HIRE_DATE  DEPARTMENT
     ------     ---------  ---------   ---------  ----------
==   123123123  JOHNSON    FRED        870507      MIS
==   123764317  IRVING     JOAN        820104      PRODUCTION
==   126724188  ROMANS     ANTHONY     820701      PRODUCTION
==   219984371  MCCOY      JOHN        810701      MIS
==   326179357  BLACKWOOD  ROSEMARIE   820401      MIS
==   451123478  MCKNIGHT   ROGER       820202      PRODUCTION
==   543729165  GREENSPAN  MARY        820401      MIS
==   818692173  CROSS      BARBARA     811102      MIS
------------------------------INPUT------------------------------------
==
 
==>
  0 Keys Changed 0 Non-Keys Changed
  0 Records Deleted 1 Records Input
 
                                                             MORE=>

If you do not type "I" in the prefix area when you input a new instance, FSCAN displays an error message. To continue, you must do one of the following:

Note that the RESET command entered on the command line is an immediate command. However, the R prefix-area command is not an immediate command. If you typed changes on a line not specifying the R prefix, FSCAN enters the changes.



x
Updating Non-Key Field Values

How to:

There are three ways to update non-key field values:

Note that FSCAN does not accept any new field value that does not conform to the ACCEPT attribute in the Master File (the ACCEPT attribute is explained in the Describing Data manual).



x
Procedure: How to Type Over Field Values

You may update segment instances by typing over their values on the screen. Use the Tab key to jump from field to field within the same instance.



Example: Typing Over Field Values

For example, suppose you want to change Richard Smith's department from Production to Sales. Simply type over the DEPARTMENT value and press Enter. The screen appears as shown on the next page. Note that the message at the bottom of the screen indicates one changed non-key field.

The screen is:

FSCAN FILE EMPLOYEEFOCUS A1             CHANGES :0
 
      EMP_ID     LAST_NAME  FIRST_NAME  HIRE_DATE  DEPARTMENT
      ------     ---------  ----------  ---------  ----------
==    071382660  STEVENS    ALFRED      800602     PRODUCTION
==    112847612  SMITH      MARY        810701     MIS
==    117593129  JONES      DIANE       820501     MIS
==    119265415  SMITH      RICHARD     820104     SALES
==    119329144  BANNING    JOHN        820801     PRODUCTION
==    123764317  IRVING     JOAN        820104     PRODUCTION
==    126724188  ROMANS     ANTHONY     820701     PRODUCTION
==    219984371  MCCOY      JOHN        810701     MIS
==    326179357  BLACKWOOD  ROSEMARIE   820401     MIS
==    451123478  MCKNIGHT   ROGER       820202     PRODUCTION
--------------------------------INPUT----------------------------------
==
==>
  0 Keys Changed 1 Non-Keys Changed
  0 Records Deleted 0 Records Input
 
                                                            MORE=>

The message at the bottom of the screen indicates the number of field values you changed since the last time you pressed Enter. The counter at the top of the screen counts the total number of values you changed since the last time the changes were saved on disk.

If you type over field values and change your mind before you press Enter, you can restore the original field values by entering R (to specify the RESET command) on the prefix area next to the instance whose values you are recovering, or by pressing the PF2 or PF14 key. However, if you press Enter before pressing one of these keys, you will not recover the typed-over values.

Note that the RESET command entered on the command line is an immediate command. However, the R prefix area command is not an immediate command. If you typed changes on a line not specifying the R prefix, FSCAN enters the changes.



x
Syntax: How to Replace Field Values: The REPLACE Command

The REPLACE command replaces one field value with another either for a specific instance or for all the instances in a group. (In the root segment, this is all the instances in the segment; in a descendant segment, this is all the instances that share a parent instance.) The syntax is

REPlace field1 = value1[,field2 = value2, ...] [,$ {*|n}]

where:

fieldn ...

Is a field in the current instance whose value you want to change.

valuen ...

Is a new value for the field.

,$ {*|n}

Enables you to change multiple instances starting from the current instance (the current instance included). n is the number of instances to be searched for the field value you want to change. If you want all instances in the group starting from the current instance changed, use an asterisk (*).



Example: Using REPLACE

For example, to change Richard Smith's department from Production to Sales, make Richard Smith's instance the current instance. Then enter:

REPLACE DEPARTMENT = SALES

To change the DEPARTMENT value to SALES in the next five instances, enter:

REPLACE DEPARTMENT = SALES,$ 5

To change all DEPARTMENT values in the group to SALES, make the first instance on display the current instance by entering:

FIRST

Then enter:

REPLACE DEPARTMENT = SALES,$ *


x
Syntax: How to Change Character Strings Within Field Values: The CHANGE Command

The CHANGE command changes character strings within field values either for a specific instance or for all the instances in a group (in the root segment, this is all the instances in the segment; in a descendant segment, this is all the instances that share a parent instance). The fields must be alphanumeric. The syntax is

CHAnge field = /oldstring/newstring/ [,$ {*|n}]

where:

field

Is the name of the field in the current instance whose value you want to change. The field must be alphanumeric, and it cannot be a key field.

oldstring

Is the substring of the field value that you want to change.

newstring

Is the character string to replace the substring.

,$ {*|n}

Enables you to change multiple instances counting from the current instance (the current instance included). n is the number of instances to be searched for the substring. If you want all instances in the group searched, starting from the current instance, use an asterisk (*).



Example: Using CHANGE

For example, to change Joan Irving's department from Production to Products, make Joan Irving's instance the current instance. Then enter:

CHANGE DEPARTMENT = /ION/S/

To change the Production department to Products in the next five instances starting from the current instance, enter:

CHANGE DEPARTMENT = /ION/S/,$ 5

To change this substring in all the instances in the group, make the first instance on display the current instance by entering:

FIRST

Then enter:

CHANGE DEPARTMENT = /ION/S/ ,$ *

Top of page

x
Changing Key Field Values

How to:

FSCAN enables you to change values of key fields, either by typing over the values or by using the REPLACE KEY command.

Note: FSCAN does not allow you to change a key field to a value that will make the key field values of one instance the same as another instance.

FSCAN does not accept any new key field value that does not conform to the ACCEPT attribute in the Master File (the ACCEPT attribute is explained in the Describing Data manual).



x
Procedure: How to Type Over Key Field Values: The KEY Command

To change the value of a key field, do the following:

  1. Type the new value over the old one.
  2. Either type a K in the prefix area next to the instance you are changing, or type the command:
    Key

    If you want the instance to be the current instance after its key value is changed, type K/ in the prefix area next to the instance.

  3. Press Enter.

After you change the key value, FOCUS moves the instance within the segment so that the key values remain sorted in their proper sequence. The screen shows this immediately.

Note: FOCUS does not physically move instances in the root segment, although the instances appear on the FSCAN screen sorted by their key field values.

If you do not enter the KEY command or type K in the prefix area when you change a key field value, FSCAN displays an error message. Before continuing, you must do one of the following:

Note: The RESET command entered on the command line is an immediate command. However, the R prefix area command is not an immediate command. If you type any changes on a line that does not specify the R prefix, FSCAN enters the changes.



Example: Using KEY

For example, suppose you want to change Alfred Stevens' employee ID from 071382660 to 444555666, and you want his instance to remain the current instance. Type over the employee ID and type K/ in the prefix area.

The screen appears as shown below:

FSCAN FILE EMPLOYEEFOCUS A1             CHANGES :2
 
     EMP_ID    LAST_NAME  FIRST_NAME  HIRE_DATE  DEPARTMENT
     ------    ---------  ----------  ---------  ----------
k/   444555666 STEVENS    ALFRED      800602     PRODUCTION
==   112847612 SMITH      MARY        810701     MIS
==   117593129 JONES      DIANE       820501     MIS
==   119265415 SMITH      RICHARD     820104     PRODUCTION
==   119329144 BANNING    JOHN        820801     PRODUCTION
==   123764317 IRVING     JOAN        820104     PRODUCTION
==   126724188 ROMANS     ANTHONY     820701     PRODUCTION
==   219984371 MCCOY      JOHN        810701     MIS
==   326179357 BLACKWOOD  ROSEMARIE   820401     MIS
==   451123478 MCKNIGHT   ROGER       820202     PRODUCTION
-------------------------------INPUT-----------------------------------
==
==>
                                                             MORE=>

When you press Enter, the screen appears as shown below:

FSCAN FILE EMPLOYEEFOCUS A1            CHANGES :3
 
     EMP_ID    LAST_NAME FIRST_NAME HIRE_DATE DEPARTMENT
     ------    --------- ---------- --------- ----------
==   444555666 STEVENS   ALFRED     800602    PRODUCTION
==   451123478 MCKNIGHT  ROGER      820202    PRODUCTION
==   543729165 GREENSPAN MARY       820401    MIS
==   818692173 CROSS     BARBARA    811102    MIS
------------------------------INPUT------------------------------------
==
==>
  1 Keys Changed 0 Non-Keys Changed
  0 Records Deleted 0 Records Input
 
                                                             MORE=>

The message at the bottom of the screen indicates the number of key field values you changed since the last time you pressed Enter.



x
Syntax: How to Change Key Field Values Using the REPLACE KEY Command

You may also use the REPLACE command to change key fields of the current instance. The syntax of the REPLACE command to replace key fields is

REPlace KEY key1 = value1[, key2 = value2, ...]

where:

keyn ...

Is the key field you want to change. Remember that an instance may have more than one key field (as determined by the SEGTYPE attribute in the Master File).

valuen ...

Is the new value for the key field.



Example: Using REPLACE KEY

For example, to change Alfred Stevens' employee ID from 444555666 to 071382660, make his instance the current instance by placing a slash in the prefix area, and enter the following:

REPLACE KEY EMP_ID = 071382660

Top of page

x
Deleting Segment Instances: The DELETE Command

How to:

You can easily delete a data instance with the DELETE command.



x
Syntax: How to Delete Segment Instances

To delete the current instance, type a D in the prefix area next to the instance or enter:

DElete

FSCAN displays the complete segment instance alone on the screen and asks if you really want to delete it. Press Enter to delete the instance, or respond:

N

Do not delete the current instance. (Returns to the previous screen.)

Q

Do not delete the current instance. (If you made no other changes to the database, entering Q leaves FSCAN and returns to the FOCUS prompt. Otherwise, it returns to the previous screen.)

Note: When you delete an instance, you delete all its descendant instances as well.



Example: Using DELETE

For example, suppose you want to delete information about John Banning from the database. First, make John Banning's instance the current instance. Then, enter the DELETE command. The following screen appears:

FSCAN FILE EMPLOYEEFOCUS A1            CHANGES :4
 
            Delete Confirmation Screen
 
           EMP_ID : 119329144          LAST_NAME : BANNING
       FIRST_NAME : JOHN               HIRE_DATE : 820801
       DEPARTMENT : PRODUCTION          CURR_SAL : 29700.00
     CURR_JOBCODE : A17                    ED_HR :    .00
 
 
 
 
==>
      Press ENTER to delete
      Enter N(o) to abort
      Enter Q(uit) to quit session

If you press Enter, the screen appears as follows:

FSCAN FILE EMPLOYEEFOCUS A1CHANGES :2
 
     EMP_ID    LAST_NAME FIRST_NAME HIRE_DATE DEPARTMENT
     ------    --------- ---------- --------- ----------
==   123764317 IRVING    JOAN       820104    PRODUCTION
==   126724188 ROMANS    ANTHONY    820701    PRODUCTION
==   219984371 MCCOY     JOHN       810701    MIS
==   326179357 BLACKWOOD ROSEMARIE  820401    MIS
==   451123478 MCKNIGHT  ROGER      820202    PRODUCTION
==   543729165 GREENSPAN MARY       820401    MIS
==   818692173 CROSS     BARBARA    811102    MIS
-------------------------------INPUT-----------------------------------
==
==>
 
0 Keys Changed 0 Non-Keys Changed
1 Records Deleted 0 Records Input
 
                                                           MORE=>

Information Builders