Previous Topic: Demonstration (2): Creating a Table from the DatabaseNext Topic: Demonstration (4): Creating a Totals-only Table


Demonstration (3): Creating a Table from an Existing Table

Objective

This example selects all part-time workers from a table (ALL-EMPLOYEES) and creates a new table (PART-TIME) for part-time employees.

The required keywords for the INPUT parameter are similar to those shown earlier in this chapter for the OUTPUT parameter.

Parameters

INPUT TABLE=ALL- EMPLOYEES TYPE=COPY USER=DOC1 PW=DOC1 *CATALOG=ASFDICT

INPUT identifies the incoming data.

TABLE=ALL-EMPLOYEES names the table. TABLE= must be the first keyword on the INPUT parameter.

TYPE=COPY copies the EMPLOYEE table. TYPE= must be the second keyword on the INPUT parameter.

USER=DOC1 PW=DOC1 identifies the user and password for signing on to the catalog (dictionary).

CATALOG=ASFDICT identifies the catalog containing the table definition.

SELECT EMPLOYEES WHEN STATUS EQ 'PT'

SELECT retrieves only part-time employees.

02OUTPUT TABLE=PART-TIME TYPE=CREATE USER=DOC1 PW=DOC1 *CATALOG=ASFDICT ONLINE=YES

OUTPUT identifies the OUTPUT parameter, which includes the CREATE instruction.

TABLE=PART-TIME names the new table. TABLE= must be the first keyword on the OUTPUT parameter.

TYPE=CREATE specifies a new table.

USER=DOC1 PW=DOC1 identifies the authorized user and password for signing on to the catalog.

CATALOG=ASFDICT identifies the catalog (dictionary) containing the table definition.

ONLINE=YES creates dialogs and maps to view the table online through ASF.

02SORT NAME

SORT alphabetizes the names.

Complete Code

 DATABASE DICTNAME=TSTDICT
 INPUT TABLE=ALL-EMPLOYEES TYPE=COPY USER=DOC1 PW=DOC1
*CATALOG=ASFDICT
 SELECT EMPLOYEES WHEN STATUS EQ 'PT'
 02OUTPUT TABLE=PART-TIME TYPE=CREATE USER=DOC1 PW=DOC1
*CATALOG=ASFDICT ONLINE=YES
 02SORT NAME
 0251*001 ID
 0251*002 NAME