I assume you got the error "ORA-12704: character set mismatch" because your data inside quotation marks is considered char, but your fields are nchar, so char is mapped using different encodings, one uses NLS_CHARACTERSET , the other NLS_NCHAR_CHARACTERSET .
When you use the UNISTR function, it converts the data from char to nchar (in any case, which also converts encoded values to characters) as Oracle docs say:
"UNISTR takes as argument a text literal or expression that resolves character data and returns it in a national character set."
If you explicitly convert values using N or TO_NCHAR you get only NLS_NCHAR_CHARACTERSET values without decoding. If you have values encoded in this way "\00E0" , they will not be decoded and will be considered unchanged.
So, if you have an insert, for example:
insert into select N'my string with special chars like \00E0', UNISTR('my string with special chars like \00E0') from dual ....
your data in the first input field will be: 'my string with special chars like \00E0' not 'my string with special chars like à' . This is the only side effect that I know of. Other requests should already use the NLS_NCHAR_CHARACTERSET encoding, so this should not be a problem with an explicit conversion.
And by the way, why not just insert all the values like N'my string with special chars like à' ? Just encode them in UTF-16 (I assume you are using UTF-16 for nchars) first if you use different encoding in top level software.
Mikhailov Valentine
source share