I found a weird situation in Oracle
Situation Faced
I used substr to split the character one by one and if the byte of length >= 2 then replace it with spacing.
It work successfully in my session but it not work in the Oracle Job. I found that it would possibility that replace more characters like Aöasd It will return with value A sd
For my further testing, I think this is because the NLS Settings
- Database's NLS Settings = 'German.Germany.AL32UTF8'
- User's Session's NLS Settings = 'AMERICAN.AMERICA.AL32UTF8'
In German.Germany.AL32UTF8 the substr function unable to grab the correct character especially after the German Special Character. However it is work in User's Session
Besides that, I also had try to use regex_replace but it is also not work for the Oracle Job it unable to replace it.
string:= REGEXP_REPLACE(ps_string, '[äöüßÄÖÜ]', ' ');
Instead of changing on the NLS Settings is there have any other solution for this?
Your problem is different character set in different database.
In my database with NLS Settings = 'AMERICAN.AMERICA.AL32UTF8'
Now, I tried the same query in my other DB with German character set and result is 1 for all characters. (
WE8ISO8859P15)The thing is in
WE8ISO8859P15character set, It takes only 1 byte to store it rather then 2 Bytes.Solution:
Use the
CONVERTfunction to convert each character toUTF8and then check the length of the character in terms of byte and replace it if it is greater than 1.Query:
Result in DB with NLS Settings = 'AMERICAN.AMERICA.AL32UTF8'
Result in DB with NLS Settings = 'German.Germany.AL32UTF8'