0
Well I have several emails with problems at the end ex: hotmal without the . com @gmail without the . com, etc.
What I am trying to do in oracle database, I look for gmail.com with the function regex_substr
, if I don’t find it I want to use a regexp_replace
to exchange the same, for several providers I use the regxp_substr
to find and if he does not find trade.
But I can’t use the function regexp_replace
in the then
, has anyone seen this? I searched and did not find.
follows the code
SELECT
email,
CASE WHEN TRIM(UPPER(regexp_substr(EMAIL,'GMAIL.COM'))THEN
REGEXP_REPLACE(UPPER(EMAIL),'GMAIL','GMAIL.COM')
END EMAIL
FROM EMAIL
Thought of a case-by-case Function ?
– Motta
I thought , however I am afraid to use Creativity inside the Bank and bring down rsrs, I am an intern and already seen..
– user162978
What error occurs ?
– Motta
It was a logic error, where I didn’t pass a parameter. It follows the code for solution. 
WHEN 
REGEXP_INSTR(UPPER(TRIM(UPPER(REGEXP_REPLACE(regexp_substr(desc_email,'@[^.]*'),'@','')))),'COM')<1 AND REGEXP_INSTR(UPPER(desc_email),'GMAIL')>0 AND NOT REGEXP_INSTR(UPPER(desc_email),'GMAILCOM')>0 AND NOT REGEXP_INSTR(UPPER(desc_email),'GMAIL.COM')>0 THEN REGEXP_REPLACE(UPPER(DESC_EMAIL),'GMAIL','GMAIL.COM') Else email
– user162978
@user162978, you answer your own question with the above solution.
– Dherik
@Can Gilson improve the title of your question? Reading it is not possible to find out what your question is
– Dherik
I changed, in case you have any tips I can improve
– user162978
@Gilson can get it right by removing the uppercase letters: "Email correction in SQL", would look much better. But still its title could be more technical. Example: "I can’t use the regexp_replace function with then. How do I make a replacement with Oracle condition?"
– Dherik