MASK_OUTER()

MASK_OUTER() — Converts the outer characters of a string to a mask value.

Synopsis

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

Description

The MASK_OUTER() function returns the specified string expression with 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 'XXltActiveXXXX', where the first two and last four characters are masked. To mask only the middle characters of a text string, use MASK_INNER().

Example

The following example anonymizes the results of a SELECT expression by using the MASK_OUTER() function to replace the leading and trailing three characters of each User ID with asterisks.

SELECT MASK_OUTER(user_id, 3, 3, '*'), last_name, email 
   FROM users ORDER BY last_name ASC;