gpt4 book ai didi

sql - 字符集不匹配 oracle 错误

转载 作者:行者123 更新时间:2023-12-04 05:00:48 26 4
gpt4 key购买 nike

我有一个这样的 SQL 语句:

SELECT QUOTE_CREATION.*,
CASE
WHEN (SUBSTR (QUOTE_CREATION."PO_number", 1, 3)) = 'ARA'
THEN
'TE161938'
WHEN (SUBSTR (QUOTE_CREATION."PO_number", 1, 3)) = 'HH-'
THEN
'TE161302'
WHEN (SUBSTR (QUOTE_CREATION."PO_number", 1, 3)) = 'SMT'
THEN
'TE161101'
WHEN (SUBSTR (QUOTE_CREATION."PO_number", 1, 3)) = 'AYP'
THEN
'TE108812'
WHEN (SUBSTR (QUOTE_CREATION."PO_number", 1, 3)) = 'DKR'
THEN
'TE160895'
ELSE
QUOTE_CREATION."Created_By"
END
AS CORRECT_USER_ID
FROM CCO.QUOTE_CREATION QUOTE_CREATION

但是当我尝试运行查询时,我在 CASE 表达式的“ELSE '' ”部分收到错误“字符集不匹配”。有人可以建议我在哪里做错了吗?

谢谢
桑托沙

最佳答案

QUOTE_CREATION。“Created_By”可能是 NVARCHAR2
尝试这样的事情:

SELECT QUOTE_CREATION.*,
CASE
WHEN (SUBSTR (QUOTE_CREATION."PO_number", 1, 3)) = 'ARA'
THEN
N'TE161938'
WHEN (SUBSTR (QUOTE_CREATION."PO_number", 1, 3)) = 'HH-'
THEN
N'TE161302'
WHEN (SUBSTR (QUOTE_CREATION."PO_number", 1, 3)) = 'SMT'
THEN
N'TE161101'
WHEN (SUBSTR (QUOTE_CREATION."PO_number", 1, 3)) = 'AYP'
THEN
N'TE108812'
WHEN (SUBSTR (QUOTE_CREATION."PO_number", 1, 3)) = 'DKR'
THEN
N'TE160895'
ELSE
QUOTE_CREATION."Created_By"
END
AS CORRECT_USER_ID
FROM CCO.QUOTE_CREATION QUOTE_CREATION

关于sql - 字符集不匹配 oracle 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16190112/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com