ORA-12704: 字符集不匹配

2021-12-30 00:00:00 oracle11g oracle coalesce

见鬼去吧:

select COALESCE (CORP_ID, 0) from crmuser.accounts;

为 Null 的 CORP_ID 记录返回 0 但当我这样做时:

The CORP_ID records which are Null returns 0 but when I do:

select COALESCE (EMAIL, 'NO EMAIL') from crmuser.accounts

我收到一个错误:

ORA-12704: character set mismatch

NVARCHAR2(30) 中的 EMAIL 字段.是我的数据类型,如果是,我应该怎么做才能返回默认值?

The EMAIL field in NVARCHAR2(30). Is is My Datatype and if so What should I do to return default Values?

推荐答案

你应该做的

select COALESCE (EMAIL, n'NO EMAIL') from crmuser.accounts

将文字转换为 NVARCHAR.

to convert the literal to NVARCHAR.

例如http://sqlfiddle.com/#!4/73929/1对比http://sqlfiddle.com/#!4/73929/2

相关文章