SQL/MP Reference Manual

HP NonStop SQL/MP Reference Manual523352-013
C-128
Correlation Names
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.
This example demonstrates the MOVE option. This command copies data from the
table $VOL1.SALES.PARTS to the Enscribe file $TESTVOL.SALES.PARTS,
copying only the PARTNUM and PARTDESC columns to the PARTNUMR and
PARID columns respectively:
>> COPY $VOL1.SALES.PARTS, $TESTVOL.SALES.PARTS,
+> TARGETDICT $TESTVOL.SALES, TARGETREC DFORMAT,
+> MOVE (PARTNUM TO PARTNUMR, PARTDESC TO PARTD);
A target column that does not have a source column mapped to it receives its
default value, unless no default value is defined for it, in that case COPY returns
an error.
Because the target is an Enscribe file, the command includes a TARGETREC
option to identify the DDL record definition for the Enscribe file.
This example demonstrates the FIRST KEY option, provided that a table with a
two-column key as described by this CREATE TABLE statement exists:
>> CREATE TABLE EMP (
+> EMPNUM SMALLINT, EMPNAME VARCHAR (20),
+> SALARY SMALLINT, PRIMARY KEY (EMPNUM, EMPNAME) );
The COPY command displays rows of table EMP at your terminal in hexadecimal
format, starting with the row for the employee whose employee number is 100 and
whose name is Martin Smith:
>> COPY EMP,,HEX,FIRST KEY (0, 100, "MARTIN SMITH ");
The EMPNUM column is defined as a SMALLINT, which uses two bytes of storage.
For an employee number of 100, the first byte of the EMPNUM column contains 0
and the second byte contains 100. The second byte contains 100 because the data
is shifted to the right. For the EMPNAME column, the key-value must be fully
padded to 20 characters, which is the maximum length of the VARCHAR used to
define the column.
Correlation Names
A correlation name is a name associated with a table or view in an SQL statement for
one or more of these reasons:
To distinguish the table or view from another table or view referred to in the
statement
To qualify an ambiguous column reference
To distinguish different uses of the same table
To make the query shorter