Table of Contents

Search

Taskflows

Taskflows

lpad

lpad

Adds a set of blank characters to the beginning of a string to set the string to a specified length.

Syntax

sff:lpad(
first_string
,
length
,
second_string
)
The following table describes the arguments:
Argument
Required/
Optional
Description
first_string
Required
Can be a character string. Passes the string that you want to change. You can enter any valid transformation expression.
To pass a NULL value, you must specify an empty sequence in the following format:
()
length
Required
Must be a positive integer literal. This argument specifies the length that you want for each string. When
length
is a negative number, lpad returns NULL.
second_string
Optional
Can be any string value. The characters that you want to append to the left-side of the
first_string
values. You can enter any valid transformation expression. You can enter a specific string literal. However, enclose the characters you want to add to the beginning of the string within single quotation marks, as in 'abc'. This argument is case sensitive. If you omit the
second_string
, the function pads the beginning of the first string with blank characters.
To pass a NULL value, you must specify an empty sequence in the following format:
()

Return Value

String of the specified length.
NULL if a value passed to the function is NULL or if
length
is a negative number.

Example

The following expression standardizes numbers to six digits by padding them with leading zeros.
sff:lpad(PART_NUM, 6, '0')
The following table lists some sample values and return values:
PART_NUM
RETURN VALUE
702
000702
1
000001
0553
000553
484834
484834
lpad counts the length from left to right. If the first string is longer than the length, lpad truncates the string from right to left. For example, lpad(‘alphabetical’, 5, ‘x’) returns the string ‘alpha’.
If the second string is longer than the total characters needed to return the specified length, lpad uses a portion of the second string:
sff:lpad(ITEM_NAME, 16, '*..*')
The following table lists some sample values and return values:
ITEM_NAME
RETURN VALUE
Flashlight
*..**.Flashlight
Compass
*..**..**Compass
Regulator System
Regulator System
Safety Knife
*..*Safety Knife
The following expression shows how lpad handles negative values for the
length
argument for each row in the ITEM_NAME column:
sff:lpad(ITEM_NAME, -5, '.')
The following table lists some sample values and return values:
ITEM_NAME
RETURN VALUE
Flashlight
NULL
Compass
NULL
Regulator System
NULL

0 COMMENTS

We’d like to hear from you!