OVRLAY: Overlaying a Character String

How to:

The OVRLAY function overlays a base character string with a substring. The function enables you to edit part of an alphanumeric field without replacing the entire field.


Top of page

x
Syntax: How to Overlay a Character String
OVRLAY(source_string, length, substring, sublen, position, output)

where:

source_string

Alphanumeric

Is the base character string.

stringlen

Integer

Is the number of characters in source_string and output. If this argument is less than or equal to 0, unpredictable results occur.

substring

Alphanumeric

Is the substring that will overlay source_string.

sublen

Integer

Is the number of characters in substring. If this argument is less than or equal to 0, the function returns spaces.

position

Integer

Is the position in source_string at which the overlay begins. If this argument is less than or equal to 0, the function returns spaces. If this argument is larger than stringlen, the function returns the source string.

output

Alphanumeric

Note that if the overlaid string is longer than the output field, the string is truncated to fit the field.



Example: Replacing Characters in a Character String

OVRLAY replaces the last three characters of EMP_ID with CURR_JOBCODE to create a new identification code and stores the result in a column with the format A9:

OVRLAY(EMP_ID, 9, CURR_JOBCODE, 3, 7, 'A9')

For EMP_ID of 326179357 with CURR_JOBCODE of B04, the result is 26179B04.

For EMP_ID of 818692173 with CURR_JOBCODE of A17, the result is 818692A17.


iWay Software