SQL/MP Reference Manual

HP NonStop SQL/MP Reference Manual523352-013
C-127
Examples—COPY
Examples—COPY
Suppose that in addition to the table EMPLOYEE described in the catalog
$VOL1.PERSNL, you have created an identical table EMPLOYEE described in a
catalog named $VOL2.TESTC. You must qualify the table names enough to
identify the location of each one uniquely. COPY determines which catalogs to use,
such as,
>> COPY $VOL1.PERSNL.EMPLOYEE, $VOL2.TEST.EMPLOYEE;
If the default subvolume is $VOL1.PERSNL, this 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.
This 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;
This 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. This copies the first 300
rows from $VOL1.SALES.PARTS table to $VOL1.SALES.SPAREPRT table 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;
This 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"