LPAD
The arguments are defined as follows:
stringExpression | Specifies the rightmost characters of an input string The stringExpression must be in one of the following data types:
The resultant string has the same data type as the input string, in various formats. |
length | An integer constant that specifies the length of the result. The value must be zero or a positive integer that is less than or equal to n, where n is 32704 if the input string is a character or binary string, or where n is 16352 if the input string is a graphic string. |
pad | An expression that specifies the string with which to pad. The expression must return a built-in character string, graphic string, or binary string. The data type of the input string determines the default pad string:
|
Result of the LPAD function
The data type of the resultant string depends on the data type of the stringExpression:
Input string data type | Resultant string data type |
---|---|
VARCHAR or CHAR | VARCHAR |
VARGRAPHIC or GRAPHIC | VARGRAPHIC |
VARBINARY or BINARY | VARBINARY |
The result of the function is a varying-length string that has the same CCSID of string-expression. String expression and Pad should have the same data type and the same encoding scheme. If the string expression or pad is FOR BIT DATA, no character conversion occurs.
The length attribute of the result depends on the integer. If an integer is greater than 0, the length attribute of the result is an integer. If the integer is 0, the length attribute of the result is 1.
The actual length of the resultant string is determined by the specified integer. If an integer is 0, the actual length is 0, and the result is the empty result string. If the integer is less than the actual length of the input string, the actual length is an integer and the result is truncated.
The resultant string is nullable if any argument is nullable and results in a null value if any argument is null.