Oracle中的字符集不匹配错误 [英] Character Set Mismatch Error in Oracle
本文介绍了Oracle中的字符集不匹配错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下要运行的查询:
I have following query with me that I am trying to run:
SELECT Script from (
SELECT 9 as ColOrder, ' INSERT INTO PROJ VALUES(' || ID || ',''' || Name || ''', ''' || Version || ''', ''ABCD'', sysdate , ''ABCD'', sysdate);' as Script FROM PROJ where Name like '%[Param.1]%'
union
SELECT 11 as ColOrder,' INSERT INTO PROJMOD VALUES(' || ID || ', ' || ProjID || ', ' || ModID || ', ' || ObjID || ', ''ABCD'', sysdate, ''ABCD'', sysdate);' as Script FROM PROJMOD where ProjID in ( select ID from PROJ where Name like '%[Param.1]%')
) x
Order by ColOrder
但是它给了我ORA-12704: character set mismatch error.
当我分别运行两个select语句时,它给我适当的输出,但是当我同时执行两个select时,它给tme字符集不匹配错误.
When I run both the select statement individually, it gives me proper output but when I am doing union of both select, it gives tme character set mismatch error.
这有什么问题吗?
推荐答案
您已经确认某些内容是NVARchar的..将nvarchar转换为char例如
as you've confirmed some things are NVARchar'd ..cast the nvarchar to char eg
SQL> create table tab(a nvarchar2(2));
Table created.
SQL> insert into tab values ('a');
1 row created.
SQL> select 1, 'hi' from dual
2 union all
3 select 2, a from tab;
select 1, 'hi' from dual
*
ERROR at line 1:
ORA-12704: character set mismatch
失败,因为"A"是NVARCHAR.所以to_char它:
fails as "A" is NVARCHAR. so to_char it:
SQL> select 1, 'hi' from dual
2 union all
3 select 2, to_char(a) from tab;
1 'HI'
---------- ----
1 hi
2 a
或将字符串文字"hi"转换为Nvarchar
or cast the string literal 'hi' to a Nvarchar
SQL> select 1, n'hi' from dual
2 union all
3 select 2, a from tab;
1 N'
---------- --
1 hi
2 a
这篇关于Oracle中的字符集不匹配错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文