试一试:
with testdata as
(
select 'John Doe' as name from dual
union
select ' John dow' as name from dual
union
select ' JON DOH ' as name from dual
union
select ' Joe wtf ' as name from dual
),
transdata as (
select 'JOHN DOW' as badval, 'JOHN DOE' as goodval from dual
union
select 'JON DOH' as badval, 'JOHN DOE' as goodval from dual
)
select
'"' || td.name || '"' as raw_name,
--initcap(trim(regexp_replace(nvl(tr.goodval, td.name), '(\W){2,}', ' '))) as output
initcap(nvl(tr.goodval, trim(regexp_replace(td.name, '(\W){2,}', ' ')))) as output
from testdata td, transdata tr
where upper(trim(regexp_replace(td.name, '(\W){2,}', ' '))) = tr.badval(+);
RAW_NAME,OUTPUT
" John dow",John Doe
" JON DOH ",John Doe
"John Doe",John Doe
" Joe wtf ",Joe Wtf
确保外部连接到您的翻译表。尽管如此,您也可以尝试对输入进行一些基本的清理。