![](/img/trans.png)
[英]Oracle SQL CASE Including the expression clause Error ORA-00936: missing expression
[英]Oracle SQL: missing expression error on UNION clause
我有以下SQL查询:
SELECT CASE WHEN connect_by_isleaf = 1 THEN 0
WHEN level = 1 THEN 1
ELSE -1
END AS status,
level,
name AS title,
NULL AS icon,
child_id AS value,
NULL AS tooltip,
NULL AS link
FROM (
SELECT alu.arl_user_user_id AS child_id,
alu.arl_list_list_id AS parent_id,
'0' AS type,
emp.employee_name AS name
FROM arl_list_user alu
INNER JOIN arl_user au
ON au.user_id = alu.arl_user_user_id
INNER JOIN arl_active_emp emp
ON au.arl_active_employee_id = emp.employee_id
UNION
SELECT all.arl_list_list_id AS child_id,
all.arl_list_list_id1 AS parent_id,
'1' AS type,
al.name AS name
FROM arl_list_list all
INNER JOIN arl_list al
ON al.list_id = all.arl_list_list_id
) table
START WITH child_id IN (
SELECT child_id
FROM table
WHERE type = '1'
)
CONNECT BY PRIOR child_id = parent_id
这将导致解析错误:
ORA-06550:第21行,第1列:ORA-00936:缺少表达式。
我已经进行了一些谷歌搜索,看起来“缺少表达式”通常意味着查询在某处缺少FROM子句,或者在UNION的情况下,两个联合查询没有相同数量的列。 我很确定这里不是这种情况,而且我无法弄清楚真正的问题是什么。
请不要将all
和table
(以及许多其他保留字)用作表格,列或子查询的别名...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.