NonStop SQL/MP Reference Manual

Table Of Contents
NonStop SQL/MP Reference Manual142115
C-123
Examples—COPY
If the default subvolume is $VOL1.PERSNL, the following command performs the
same function:
>> COPY EMPLOYEE, $VOL2.TEST.EMPLOYEE;
The tables have identical descriptions. You need not specify any move options;
MOVEBYORDER is used by default.
The following command displays the first 100 rows of table $VOL1.SALES.PARTS
at your terminal and specifies the octal display format:
>> COPY $VOL1.SALES.PARTS,,OCTAL COUNT 100;
The following example demonstrates the COUNT and MOVEBYNAME options.
The table SPAREPRT contains columns of the same names as the PARTS table, but
the columns in the two tables are arranged in a different order. The following copies
the first 300 rows from table $VOL1.SALES.PARTS to table
$VOL1.SALES.SPAREPRT and copies each column in the source table to the
column with the same name in the target table:
>> COPY $VOL1.SALES.PARTS, $VOL1.SALES.SPAREPRT,
+> COUNT 300 MOVEBYNAME;
The following command copies data from the Enscribe file
$VOL2.SUBV1.CLIENTS to the table $VOL1.SALES.CUSTOMER:
>> COPY $VOL2.SUBV1.CLIENTS, $VOL1.SALES.CUSTOMER,
+> SOURCEDICT $VOL2.SUBV1, SOURCEREC CLREC,
+> MOVEBYORDER, TRUNC ON;
Because the source is an Enscribe file, the command includes a SOURCEREC
option to identify the DDL record definition for the Enscribe file. The values are
copied in order from fields to columns, as shown:
Fields in Record CLREC Columns in Table CUSTOMER
02 CUSTNUM PIC 9(4). CUSTNUM DECIMAL(4) UNSIGNED,
02 CUSTNAME PIC X(20). CUSTNAME CHAR(18),
02 ADDR.
03 ADDRESS PIC X(22). STREET CHAR(22),
03 CITY PIC X(14). CITY CHAR(14),
03 STATE PIC X(2). STATE CHAR(12),
03 ZIP-CODE PIC X(6). POSTCODE CHAR(10),
CREDIT CHAR(2) DEFAULT "C1"
The CUSTNAME value is truncated because the column length is less than the field
length. The default value is used for the CREDIT column in each new row of
CUSTOMER because no source field maps to this column.