MASK_INNER()

MASK_INNER() — Converts the inner characters of a string to a mask value.

Synopsis

MASK_INNER( string-expression, leading-characters, trailing-characters [, mask-character] )

Description

The MASK_INNER() function returns the specified string expression with all but the first leading-characters and last trailing-characters characters replaced by the character mask-character. The default value for the optional argument mask-character is X, so the output of MASK_TEXT('VoltActiveData', 2, 4) is the string 'VoXXXXXXXXData',where all but the first two and last four characters are masked. To mask only the outer characters of a text string, use MASK_OUTER().

Note that MASK_PARTIAL() has the same utility as MASK_INNER() except with default mask character *.

Example

The following example anonymizes the results of a SELECT expression by using the MASK_INNER() function to replace all but the first three and last two digits of each phone number with asterisks.

SELECT last_name, MASK_INNER(phone_number, 3, 2, '*'), email, city, state
   FROM contestants ORDER BY last_name ASC;