Question

I have a table like below;

ID(int) | P_DATE(date) | EXPLANATION(varchar2)
-----------------------------------------------
1       |   22.12.2013 |   'File upload'
2       |   31.12.2013 |   'Card Payment'
3       |   24.02.2014 |   'Unit TN=5321234564'

In third row of Explanation column, there is a phone number (5321234564)

How can I mask this phone number using '*'?

After masking, select query should be return the result like below?

ID(int) | P_DATE(date) | EXPLANATION(varchar2)
-----------------------------------------------
1       |   22.12.2013 |   'File upload'
2       |   31.12.2013 |   'Card Payment'
3       |   24.02.2014 |   'Unit TN=532*****64'
Was it helpful?

Solution

If you can change query then it is simple:

select 'Unit TN=5321234564', regexp_replace('Unit TN=5321234564', 'TN=([0-9]{3})([0-9]{5})([0-9]{2})', 'TN=\1*****\3') from dual

(of course change regexp if your phone number is in other format)

If you cannot change query then rename original EXPLANATION column to EXPLANATION_ORIG, add EXPLANATION column and add trigger changing INSERT'ed or UPDATE'd data to save original data into EXPLANATION_ORIG and masked data into EXPLANATION column.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top