Previous Topic: Step 3: Choosing the ColumnsNext Topic: Step 5: Selecting Rows


Step 4: Adding a Column

Added Columns not Stored

You might want to add a column to a view so you can perform calculations on data supplied by the view. The added column is for display purposes only; it is not stored in the database because it is not part of the source tables from which the view is derived.

Define the Column

To continue the example, add the SALARY DIFFERENTIAL column to the JOBS AND APPLICANTS view, as follows:

                                                      CA   CDEF   CA - Automatic System Facility            ** Column Definition **   DC560307 COLUMNS UPDATED   Table Name: JOBS AND APPLICANTS       _ PF1 - Help                         _ PF3 - Extended Selection Definition       X PF2 - Extended Column Definition   _ PF4 - Extended Key Definition         Page:  1  of  1                                                  Unique  Display   Ext            Column Name             Width   Type    Key     Seq    Screen   JOB NUMBER                           4 TEXT                2      _   DEPARTMENT                          20 TEXT                4      _   TITLE                               30 TEXT                6      _   SALARY                               7 CURRENCY            8      _   CURRENT STATUS (FILLED OR OPEN)      6 TEXT                       _   NAME                                30 TEXT               10      _   POSITION APPLIED FOR                30 TEXT                       _   SALARY REQUIREMENT                   7 CURRENCY           12      _   EVALUATION: STRONG,WEAK,MEDIUM       6 TEXT               14      _   salary differential              7     c                16        x

Extended Column Definition

The Extended Column Definition (XCOL) screen is displayed. This screen shows the column characteristics that are supplied by ASF when you define a column. For most columns, you do not need to review the extended definition; the characteristics supplied by ASF are sufficient for the column definition. For columns added to views, you have to supply additional information to fully define the column.

Define the Calculation

You want the SALARY DIFFERENTIAL column to calculate the difference between the salary an applicant requires and the salary available for the position. Define the SALARY DIFFERENTIAL column by entering the arithmetic expression column(salary requirement) - salary in the Calculation field.

Embedded Spaces

Since the SALARY REQUIREMENT column name contains an embedded space, you must refer to it using COLUMN(column-name).

For more information on specifying calculations, see the chapter "Extended Functions of ASF".

                                                      CA   XCOL   CA - Automatic System Facility          *Extended Column Definition*   DC560407 MODIFY COLUMN DEFINITION   Table Name: JOBS AND APPLICANTS           _ PF1 - Help      _ PF2 - Next Column      _ PF3 - Message Screen            Displayed Column Name                    Stored Column Name      SALARY DIFFERENTIAL                     SALARY-DIFFERENTIAL               Display Format                          Stored Format      -Z(05).9(02)                            S9(05)V9(02)   Usage: 3 D/0/1/2/3  Display/Comp/Comp-1/Comp-2/Comp-3        IDD Version:   Comments.....:                                           Column Level: WORK   Initial Value:   Calculation..: column(salary requirement) - salary   Edit Table:           Version:           Code Table:           Version:    U  U/P   Unprotected/Protected  N  B/R/P/T/G/Y/W/N  Blue/Red/Pink/Turquoise                                                        Green/Yellow/White/Nocolor    N  Y/N   Blank When Zero        N  N/R  Normal/Reverse Video    D  B/D/K Bright/Display/Dark    N  Y/N  Blink/Noblink

What You Will See

Whenever the JOBS AND APPLICANTS view is accessed, ASF will subtract the value in the SALARY column from the value in the SALARY REQUIREMENT column and display the result in the SALARY DIFFERENTIAL column.

Press [Enter]. The message COLUMN DEFINITION MODIFIED is displayed on the message display line. Press [PF2] to return to the Column Definition screen.