When Union all is used for join, if a column in a set is of the nvarchar2 or nvarchar type, but this column is not included in Set B, ''is used to replace the reported Character Set mismatch.There are two solutions:
Problematic SQL:
Select 'China', 'China', cast ('China' as nvarchar2 (10) T
From dual
Union all
Select 'USA ', 'USA ',''
From dual;
As shown above, the T type is nvarchar2 and the length is 10. If this is the case, the character set does not match. How can this problem be solved?
1. to_char ()
Select 'China', 'China', to_char (cast ('China' as nvarchar2 (10) T
From dual
Union all
Select 'USA ', 'USA ',''
From dual;
2. n'' and n'' are used to convert ''to unicode encoding.
Select 'China', 'China', cast ('China' as nvarchar2 (10) T
From dual
Union all
Select 'USA ', 'USA', n''
From dual;
ORA-12704 in Union: solution to Character Set mismatch Problem