oracle ORA-12704: 字符集不匹配
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15967201/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ORA-12704: character set mismatch
提问by ErrorNotFoundException
Hell when I do:
地狱当我这样做:
select COALESCE (CORP_ID, 0) from crmuser.accounts;
The CORP_ID records which are Null returns 0 but when I do:
为 Null 的 CORP_ID 记录返回 0 但当我这样做时:
select COALESCE (EMAIL, 'NO EMAIL') from crmuser.accounts
I get an error:
我收到一个错误:
ORA-12704: character set mismatch
The EMAIL field in NVARCHAR2(30). Is is My Datatype and if so What should I do to return default Values?
NVARCHAR2(30) 中的 EMAIL 字段。是我的数据类型,如果是,我应该怎么做才能返回默认值?
回答by DazzaL
you should do
你应该做
select COALESCE (EMAIL, n'NO EMAIL') from crmuser.accounts
to convert the literal to NVARCHAR.
将文字转换为 NVARCHAR。
eg http://sqlfiddle.com/#!4/73929/1vs http://sqlfiddle.com/#!4/73929/2
例如 http://sqlfiddle.com/#!4/73929/1vs http://sqlfiddle.com/#!4/73929/2
回答by Cristi S.
This generic fix works with columns defined as either VARCHAR2 or NVARCHAR2:
此通用修复适用于定义为 VARCHAR2 或 NVARCHAR2 的列:
select COALESCE (EMAIL, N'' || 'NO EMAIL') from crmuser.accounts
Just add N'' || before your non-Unicode string constant.
只需添加 N'' || 在非 Unicode 字符串常量之前。