MASK_CCN()

MASK_CCN() — Converts the middle digits of a credit or payment card number to a mask value.

Synopsis

MASK_CCN( string-expression [, leading-digits [, mask-character]] )

Description

The MASK_CCN() function returns the specified string expression with all but the first leading-digits and last four digits replaced by the character mask-character. The default values for the optional arguments leading-digits and mask-character are 0 and X, respectively. Separators included in the string expression are ignored and carried through unchanged into the output, so that the output of MASK_CCN('4111-1111-1111-1111', 3) is the string '411X-XXXX-XXXX-1111', where all but the first three and last four digits are masked.

Example

The following example creates a VIEW using the MASK_CCN() function to mask all but the last four digits of each credit card number.

CREATE VIEW payments AS
   SELECT last_name, MASK_CCN(credit_card_number), date, amount 
      FROM customer_payments ORDER BY date DESC;