Try OpenEdge Now
skip to main content
SQL Reference
SQL Reference : OpenEdge SQL Functions : LPAD
 

LPAD

Pads the character string corresponding to the first argument on the left with the character string corresponding to the third argument. After the padding, the length of the result is length.

Syntax

LPAD ( char_expression , length[ , pad_expression] )

Notes

*The first argument to the function must be of type CHARACTER. The second argument to the function must be of type INTEGER. The third argument, if specified, must be of type CHARACTER. If the third argument is not specified, the default value is a string of length 1 containing one blank.
*If L1 is the length of the first argument and L2 is the value of the second argument:
*If L1 is less than L2, the number of characters padded is equal to L2 minus L1.
*If L1 is equal to L2, no characters are padded and the result string is the same as the first argument.
*If L1 is greater than L2, the result string is equal to the first argument truncated to the first L2 characters.
*The result is of type CHARACTER.
*If the argument expression evaluates to NULL, the result is NULL.
*The char_expression and pad_expression can contain multi‑byte characters. The length specifies a number of characters.

Example

This example illustrates two ways to use the LPAD function:
SELECT LPAD (last_name, 30) FROM customer ;
SELECT LPAD (last_name, 30, '.') FROM customer ;

Compatibility

Progress extension