2

我有一个这样的 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”部分收到错误“字符集不匹配”。有人可以建议我在哪里做错了吗?

谢谢桑托莎

4

1 回答 1

3

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
于 2013-04-24T11:24:42.123 回答