SPACE

The SPACE function returns a character string that consists of the number of SBCS blanks that the argument specifies.

SPACE(expression)
expression
An expression that returns a value of any built-in SMALLINT, INTEGER, BIGINT, character-string, or graphic-string data type. A string argument is converted to integer before evaluating the function. For more information about converting strings to integer, see INTEGER or INT.

The expression specifies the number of SBCS blanks for the result, and it must be between 0 and 32740. If expression is a constant, it must not be the constant 0.

The result of the function is a varying-length character string (VARCHAR) that contains SBCS data.

If expression is a constant, the length attribute of the result is the constant. Otherwise, the length attribute of the result is 4000. The actual length of the result is the value of expression. The actual length of the result must not be greater than the length attribute of the result.

If the argument can be null, the result can be null; if the argument is null, the result is the null value.

The CCSID is the default CCSID for SBCS data of the job.

Example

  • The following statement returns a character string that consists of 5 blanks.
      SELECT SPACE(5)
        FROM SYSIBM.SYSDUMMY1