COPY (Include library text)

Function

COPY includes (copies) a source library text into the source program.

Format

COPY source-text-name

Operands

source-text-name
Specifies the name of the file (exclusive of the suffix) that contains either library text or a header file, as a character string of 30 characters or less.

Common rules

  1. COPY must be enclosed between an SQL prefix and an SQL terminator.
    The SQL terminator must be the last item of coding through the end of the row.
  2. Directories in which library text and header files are cataloged are searched in the following sequence; the directories should therefore be stored in one of the files listed below:
    Order in which directories are searched
    • Directories cataloged by means of an environment variable (PDCBLLIB in the case of COBOL or OOCOBOL; PDCLIB in the case of C or C++)
    • Current directory
    Order in which files are searched (for COBOL and OOCOBOL)
    • Suffixed files stored by PDCBLFIX environment variable
    • file-name.cbl
    • file-name.CBL
    • file-name.cob
    Order in which files are searched (for C and C++)
    • file-name.h
  3. In SQL, COPY cannot be specified in a text included by COPY.
  4. With COBOL or OOCOBOL, the library text must be specified in the fixed-format reference format.

Notes

A source library text that contains embedded variables or SQL statements should not be included using the COPY or INCLUDE statement of COBOL or OOCOBOL.

The #include instruction of C or C++ must not be used to include a file that contains SQL statements.

Example

Include the source library text with file name SAMPLE into the source program:

COBOL language

EXEC SQL
  COPY SAMPLE
END-EXEC.