The REPEAT function returns a string composed of expression repeated integer times.
The data type of the result of the function depends on the data type of the first argument:
Data type of string-expression | Data type of the Result |
---|---|
CHAR or VARCHAR or any numeric type | VARCHAR |
CLOB | CLOB |
GRAPHIC or VARGRAPHIC | VARGRAPHIC |
DBCLOB | DBCLOB |
BINARY or VARBINARY | VARBINARY |
BLOB | BLOB |
If integer is a constant, the length attribute of the result is the length attribute of string-expression times integer. Otherwise, the length attribute depends on the data type of the result:
If the length attribute of the result exceeds the maximum for the result data type, an error is returned.
The actual length of the result is the actual length of string-expression times integer. If the actual length of the result string exceeds the maximum for the return type, an error is returned.
If either argument can be null, the result can be null; if either argument is null, the result is the null value.
The CCSID of the result is the CCSID of string-expression.49
SELECT REPEAT('abc', 2) FROM SYSIBM.SYSDUMMY1
SELECT CHAR( REPEAT('REPEAT THIS', 5), 60) FROM SYSIBM.SYSDUMMY1This example results in 'REPEAT THISREPEAT THISREPEAT THISREPEAT THISREPEAT THIS '.
SELECT LENGTH( REPEAT('REPEAT THIS', 0) ) FROM SYSIBM.SYSDUMMY1
SELECT LENGTH( REPEAT('', 5) ) FROM SYSIBM.SYSDUMMY1
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.