REPEAT (SYSFUN schema) scalar function
Returns a character string composed of the first argument repeated the number of times specified by the second argument.
The schema is SYSFUN.
- expression1
- An expression that returns a value of built-in character string, graphic string, or binary
string data type. In a Unicode database, the expression can also return a graphic string, in which
case it is first converted to a character string before the function is evaluated. The maximum
length is:
- 4000 bytes for a VARCHAR
- 1,048,576 bytes for a CLOB or binary string
- expression2
- An expression that returns a value of data type SMALLINT or INTEGER. The returned value specifies the number of times to repeat the string returned by expression1.
Result
The data type of the result is:
- VARCHAR(4000 OCTETS) if the first expression returns a CHAR or VARCHAR value
- CLOB(1M OCTETS) if the first expression returns a CLOB value
- BLOB(1M) if the first expression returns a BLOB value
The result can be null; if any argument is null, the result is the null value.
Examples
List the phrase 'REPEAT THIS' five times.
VALUES REPEAT('REPEAT THIS', 5)
This example returns the
following VARCHAR(4000 OCTETS) output:
1
------------------------------------------------------------
REPEAT THISREPEAT THISREPEAT THISREPEAT THISREPEAT THIS
List the phrase 'REPEAT THIS' five times and limit the output to 60
bytes:
VALUES CHAR(REPEAT('REPEAT THIS', 5), 60)
This
example returns the following CHAR(60)
output:1
------------------------------------------------------------
REPEAT THISREPEAT THISREPEAT THISREPEAT THISREPEAT THIS