有人可以告诉我一个很好的方法来检查在如下查询中如何以及在何处可能缺少(或过多)括号?
例如,此查询返回错误,即它缺少右括号。但是哪里??? !
SELECT * FROM ( SELECT X.*, ROWNUM AS RN FROM (SELECT ORG_UNIT, QUEUE_NAME, CASE_STATUS, AGENT_ROLE, COUNT(*) AS CASE_COUNT
FROM
(
SELECT ORG_UNIT, QUEUE_NAME, CREATION_TIMESTAMP, CASE_STATUS, AGENT_ROLE
FROM
( SELECT OU.NAME AS ORG_UNIT, D.NAME AS QUEUE_NAME,
WS.NAME AS CASE_STATUS, C.ASSIGNED_TO AS AGENT_ID, C.CREATION_TIMESTAMP AS CREATION_TIMESTAMP,
CASE NVL(C.ASSIGNED_TO, -1) WHEN -1 THEN 'Unassigned' ELSE RU.ROLE_NAME END AS AGENT_ROLE
FROM CASES C
JOIN ORGANIZATION_UNITS OU ON OU.ID = C.ORGUNIT_ID
JOIN WORKFLOW_STATUSES WS ON WS.ID = C.STATUS_ID
JOIN DOMAINS D ON D.ID = C.DOMAIN_ID
JOIN DOMAINS DP ON DP.ID = D.PARENT_ID
LEFT OUTER JOIN (SELECT DISTINCT C.ASSIGNED_TO AS AGENT_ID, RL.NAME AS ROLE_NAME
FROM CASES C
JOIN DOMAINS D ON D.ID = C.DOMAIN_ID
JOIN DOMAINS DP ON DP.ID = D.PARENT_ID
JOIN USER_GROUP_RELATIONS UGR ON UGR.USER_ID = C.ASSIGNED_TO
JOIN GRP_ORG_DOM_ROLE_RELATIONS GODRR ON (GODRR.GROUP_ID = (SELECT MAX(UGR.GROUP_ID)
FROM USER_GROUP_RELATIONS UGR
WHERE UGR.USER_ID = C.ASSIGNED_TO)
AND GODRR.DOMAIN_ID =C.DOMAIN_ID
AND GODRR.ORGANIZATION_ID = C.ORGUNIT_ID)
JOIN ROLES RL ON RL.ID = (SELECT MAX(GODRR.ROLE_ID)
FROM GRP_ORG_DOM_ROLE_RELATIONS GODRR
WHERE GODRR.GROUP_ID = UGR.GROUP_ID
AND GODRR.ORGANIZATION_ID = C.ORGUNIT_ID AND GODRR.DOMAIN_ID = C.DOMAIN_ID)
WHERE DP.NAME='DD') RU ON RU.AGENT_ID = C.ASSIGNED_TO
WHERE DP.NAME='DD'
) WHERE 1=1
)
GROUP BY ORG_UNIT, QUEUE_NAME, CASE_STATUS, AGENT_ROLE
ORDER BY ORG_UNIT, QUEUE_NAME, CASE_STATUS, AGENT_ROLE order by ORG_UNIT asc ) X ) WHERE RN > 0 AND RN <= 10
答案 0 :(得分:2)
Crimson Edit和许多其他文本编辑器和IDE都有大括号匹配。
http://en.wikipedia.org/wiki/Crimson_Editor
如果大括号匹配,但嵌套错误,则可能需要更改缩进策略。
此外,代码格式化工具有时可以清楚地表明你错过了paren或嵌套错误。
这是一个在线地方,您可以粘贴代码以查看其重新格式化。