oracle查询中的标识符无效

时间:2018-11-01 15:06:26

标签: oracle plsql case-when

我有以下查询:

SELECT 
FIRST_NAME AS "NAME",
CASE COUNTRY
    WHEN "FR" THEN "FRANCE"
    WHEN "USA" THEN "UNITED STATES"
    WHEN "C RO" THEN NULL
ELSE COUNTRY 
    END AS "COUNTRY"
FROM RAWDATA

向前看似乎很困难,但出现以下错误:

ociexecute(): ORA-00904: "C RO": invalid identifier in path

我对oracle还是很陌生,所以可以帮助您。

1 个答案:

答案 0 :(得分:3)

尝试一下。 oracle中的字符串文字用单引号引起来。双引号用于括起标识符(如表名和列名),但在您的示例中不需要。

SELECT 
FIRST_NAME AS NAME,
CASE COUNTRY
    WHEN 'FR' THEN 'FRANCE'
    WHEN 'USA' THEN 'UNITED STATES'
    WHEN 'C RO' THEN NULL
ELSE 'COUNTRY'
    END AS COUNTRY
FROM RAWDATA