oracle 字符集不匹配

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1109811/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 18:35:01  来源:igfitidea点击:

Character set mismatch

sqloracle

提问by

I have a SQL statement like this:

我有一个这样的 SQL 语句:

SELECT 
  a.ColumnA, b.ColumnB || 
 CASE WHEN TRIM(c.ColumnC) IS NOT NULL THEN ' (' || c.ColumnC || ')' ELSE '' END AS ClassName
 FROM TableA a INNER JOIN TableB b ON a.SomeColumn = b.SomeColumn 
 INNER JOIN TableC c on a.SomeCol = c.SomeCol

I'm getting an error "Character set mismatch" at the " ELSE '' " part of the CASE expression. Can someone suggest where I'm doing it wrong? Thank you.

我在 CASE 表达式的“ ELSE '' ”部分收到错误“字符集不匹配”。有人可以建议我在哪里做错了吗?谢谢你。

回答by Adam Hawkes

You cannot concatenate VARCHAR and NVARCHAR values without a CAST statement.

您不能在没有 CAST 语句的情况下连接 VARCHAR 和 NVARCHAR 值。

回答by Matt Birchall

CASE WHEN TRIM(c.ColumnC) IS NOT NULL 
     THEN ' (' || c.ColumnC || ')' 
     ELSE N'' END A

is a more concise solution. N'' gives you a unicode empty string

是一个更简洁的解决方案。N'' 给你一个 unicode 空字符串

回答by Roger

Just erase the ELSE, would make your code easier to read

只需擦除 ELSE,将使您的代码更易于阅读

回答by jva

Did you try replacing '' with NULL? Also, try removing ELSE part altogether because it will return NULL anyway.

您是否尝试将 '' 替换为 NULL?此外,尝试完全删除 ELSE 部分,因为它无论如何都会返回 NULL。