SQL/MP Reference Manual
HP NonStop SQL/MP Reference Manual—523352-013
C-125
Considerations—COPY
When a source column is undefined and the target column is defined with the NO
DEFAULT clause, an error occurs. The source row must supply a value for every
column of the target row that is defined with the NO DEFAULT clause. In addition,
a target row must satisfy any constraint defined on the table to be inserted in the
table. The TRUNC option determines whether values are truncated. For more
information, see INSERT Statement on page I-14.
Any column except a system-defined primary key can be a source or target item.
Rules for using CLASS TAPE DEFINEs or labelled tapes are described in the
discussion of the FUP COPY command in the File Utility Program (FUP)
Reference Manual.
You cannot copy a multireel set of tapes created by a COBOL program, because
COBOL does not mark the end of a multireel set in the same way that COPY does.
You must use a COBOL program to copy such tapes. For more information, see
the COBOL Reference Manual.
Using COPY with non-SQL files
If the source is an EDIT file, COPY handles it like a structured file: each text
line is handled as a logical record with a read count attribute. (This differs from
the usual treatment of unstructured files in which each physical read, except
possibly the last read of a file, returns exactly in-record-length bytes.) If
an EDIT file record ends in the middle of a field, SQL adds blanks to the target
file for the remainder of the field.
Although you can specify a block size up to 32,767 bytes for the BLOCKIN and
BLOCKOUT parameters, some peripheral devices have smaller maximum
block sizes that must not be exceeded when using the COPY command.
Be careful when you use PAD and TRIM options. If your data contains
trim-character or pad-character, data might be added or lost. Use a
pad character or trim character that is not contained in your data. For example,
suppose that you pad each record of a file with zeros to a standard size in
bytes and then store the records in another file. If you later trim the trailing
zeros when you COPY the stored records, zeros at the end of the original data
are trimmed.
Rules for enscribe files with variable-length records
Copying Into SQL Tables
The target file must have default values defined for columns that do not have
source fields mapped to them and for all fields missing from the source record.
A column must be defined with the DEFAULT clause of the CREATE TABLE or
ALTER TABLE command. A DDL data item must be defined with the VALUE IS
clause.
If a record from a non-SQL source is not long enough to supply data to all
fields mapped to target columns, each target column whose source field is
missing must have a default value defined for it.