SPACE scalar function

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

Read syntax diagramSkip visual syntax diagramSPACE( numeric-expression)

The schema is SYSIBM.

numeric-expression
An expression that returns the value of any built-in integer data type. The expression specifies the number of SBCS blanks for the result, and it must be between 0 and 32764.

The argument can also be a character string or graphic string data type. The string input is implicitly cast to a numeric value of DECFLOAT(34) which is then assigned to a BIGINT value.

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

If numeric-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 numeric-expression. The actual length of the result must not be greater than the length attribute of the result.

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

Example: The following statement returns a character string that consists of 5 blanks followed by a zero-length string.
   SELECT SPACE(5), SPACE(0)
     FROM SYSIBM.SYSDUMMY1;