Q:

How to use masks while displaying names in tables using sql fuctions

 

if the record [name surname] it must be masked except the first two letters
if the record [name name surname] the second name must be masked too
if name and surname have only 2 letters nothing changes

A:

You can try this. I'm not very sure about how oracle will handle this query. 
select concat(substr(fn,1,2),replicate("x",len(fn)-2)," ",substr(ln,1,2),replicate("x",len(ln)-2)) as CUSTOMER_NAME_SURNAME
from (select substr(CUSTOMER_NAME_SURNAME, 1, instr(CUSTOMER_NAME_SURNAME," ")) as fn, 
        substr(CUSTOMER_NAME_SURNAME, -1, instr(CUSTOMER_NAME_SURNAME," ", -1)) as ln
        from table_name)

Or, my best bet would be to split the names in other table and use substrings with replicate. And then concatenate the names. But that will make it confusing and more than one table, I guess.
Additionally, for the middle name, you can use 
substr(CUSTOMER_NAME_SURNAME, instr(CUSTOMER_NAME_SURNAME," ")+1, instr(CUSTOMER_NAME_SURNAME," ",1,2)-1) as mn

And then use CASE WHEN with the fn, mn, and ln.

