Previous Topic Next topic Print topic


COPY Function

Purpose

Copies a particular string a certain number of times and concatenates the result into a single string.

Syntax

COPY(x,y)

Parameters

x is a character-string, bit-string, or picture value, and y is a positive integer expression. If x is an arithmetic value, it is converted to a bit string if it is binary, or to a character string if it is decimal.

Description

The COPY function copies a particular string, x, a certain number of times, y, and concatenates the result into a single string. COPY effectively returns a string containing y occurrences of the string argument, with length y* length (x).

The result is obtained by concatenating y occurrences of x together.

Examples

DECLARE X CHAR(6);
X = COPY('AB',3)   /* returns X = 'ABABAB' */

Note that the same result could be produced by using a string repetition factor, as illustrated below:

X = (3) 'AB';

Restrictions

None.

Previous Topic Next topic Print topic