为什么我的查询中的count(distinct signatory_id)会导致ORA-00600错误?

时间:2015-10-29 12:56:36

标签: sql oracle

CREATE OR REPLACE FORCE VIEW "EXPCPU_SVS"."TEMP_VW_ZZZ_SVS_DATA_IMPORT" ("ACCOUNT_TYPE", "TOTAL_ACCOUNTS", "TOTAL_SIGNATURES", "TOTAL_SIGNCARDS", "TOTAL_GROUPS", "TOTAL_RULES") AS 
SELECT flag_name            AS ACCOUNT_TYPE,
NVL(TOTAL_ACCOUNTS,0)       AS TOTAL_ACCOUNTS,
NVL(TOTAL_SIGNATURES,0)     AS TOTAL_SIGNATURES,
NVL(TOTAL_SIGNCARDS,0)      AS TOTAL_SIGNCARDS,
NVL(TOTAL_GROUPS,0)         AS TOTAL_GROUPS,
NVL(TOTAL_RULES,0)          AS TOTAL_RULES
FROM
(
SELECT flag_name,TOTAL_ACCOUNTS, TOTAL_SIGNATURES,TOTAL_SIGNCARDS,TOTAL_GROUPS,FLAG_VALUE FROM
(
SELECT flag_name,TOTAL_ACCOUNTS, TOTAL_SIGNATURES,TOTAL_SIGNCARDS,FLAG_VALUE FROM 
(
SELECT flag_name,TOTAL_ACCOUNTS,  TOTAL_SIGNATURES,flag_value
FROM 
(
SELECT flag_name,TOTAL_ACCOUNTS,flag_value 
FROM 
(
SELECT count(*)             AS TOTAL_ACCOUNTS ,
A.HISTORY_FLAG              AS a_history_flag
FROM tbl_sign_account a WHERE a.history_flag IN(0,1,2) GROUP BY a.history_flag
)
FULL OUTER JOIN
(
SELECT flag_value,flag_name FROM temp_zz_tbl_flag_mapping
)
ON flag_value=a_history_flag
)
FULL OUTER JOIN 
(
SELECT COUNT(*)             AS TOTAL_SIGNATURES,
b.history_flag              AS b_history_flag
FROM tbl_signatory b
WHERE b.history_flag IN (0,1,2)
GROUP BY b.history_flag
)
ON b_history_flag=flag_value )
FULL OUTER JOIN
(
SELECT count(distinct signatory_id)             AS TOTAL_SIGNCARDS ,
c.history_flag              AS c_history_flag
FROM  tbl_signature_card c
WHERE c.history_flag IN (0,1,2) GROUP BY c.history_flag
)
ON flag_value=c_history_flag
)FULL OUTER JOIN
(
SELECT count(*)             AS TOTAL_GROUPS,
d.history_flag              AS d_history_flag
FROM tbl_sign_group d
WHERE d.history_flag IN (0,1,2) GROUP BY d.history_flag
)
ON flag_value=d_history_flag
) 
FULL OUTER JOIN
(
SELECT count(*)             AS TOTAL_RULES,
e.history_flag              AS e_history_flag
FROM tbl_sign_rule e WHERE e.history_flag IN (0,1,2) GROUP BY e.history_flag
)
ON e_history_flag=flag_value;

这就是错误:

ORA-00600: internal error code, arguments: [kkqcscpopn_Int: 0], [], [], [], [], [], [], [], [], [], [], []
00600. 00000 -  "internal error code, arguments: [%s], [%s], [%s], [%s], [%s], [%s], [%s], [%s]"
*Cause:    This is the generic internal error number for Oracle program
           exceptions.  This indicates that a process has encountered an
           exceptional condition.
*Action:   Report as a bug - the first argument is the internal error number

1 个答案:

答案 0 :(得分:3)

ORA-00600意味着您遇到内部错误,本质上是一个错误。您可以在My Oracle Support上查找错误的详细信息;有一个关于从哪里开始ORA-00600错误的通用文档,搜索参数kkqcscpopn_Int将显示各种已知问题 - 请参阅文档ID 1267257.1以获取摘要。您将需要知道确切的版本和补丁级别以缩小可能性,并在您找不到匹配项时提出服务请求,或者怀疑您是否看到同样的事情。正如错误消息所示,报告错误是发生内部错误时的预期操作。

有时,通过重写或重新设计您正在使用的查询可以避免模糊的错误。在这种情况下,您所拥有的内容似乎过于复杂 - 不确定为什么要放入如此多级别的查询,或者确实需要完全外部联接。如果你想坚持连接到计算计数(而不是,比如说,在选择列表中有子查询),你可以尝试简单一点,看看是否有助于解析器。作为一个快速的第一次尝试,并假设您将始终在temp_zz_tbl_flag_mapping中记录您正在使用的三个标志值,我认为这大致相同:

CREATE OR REPLACE  VIEW temp_vw_zzz_svs_data_import AS
SELECT z.flag_name           AS account_type,
  NVL(a.total_accounts, 0)   AS total_accounts,
  NVL(b.total_signatures, 0) AS total_signatures,
  NVL(c.total_signcards, 0)  AS total_signcards,
  NVL(d.total_groups, 0)     AS TOTAL_GROUPS,
  NVL(e.total_rules, 0)      AS TOTAL_RULES
FROM temp_zz_tbl_flag_mapping z
LEFT JOIN (
  SELECT history_flag, COUNT(*) AS total_accounts
  FROM tbl_sign_account
  GROUP BY history_flag
) a ON a.history_flag = z.flag_value
LEFT JOIN (
  SELECT history_flag, COUNT(*) AS total_signatures
  FROM tbl_signatory
  GROUP BY history_flag
) b ON b.history_flag = z.flag_value
LEFT JOIN (
  SELECT history_flag, COUNT(DISTINCT signatory_id) AS total_signcards
  FROM tbl_signature_card
  GROUP BY history_flag
) c ON c.history_flag = z.flag_value
LEFT JOIN (
  SELECT history_flag, COUNT(*) AS total_groups
  FROM tbl_sign_group
  GROUP BY history_flag
) d ON d.history_flag = z.flag_value
LEFT JOIN (
  SELECT history_flag, COUNT(*) AS total_rules
  FROM tbl_sign_rule
  GROUP BY history_flag
) e ON e.history_flag = z.flag_value
WHERE z.flag_value in (0,1,2);

如果您可能没有该表/视图中的所有标志值,则可能需要返回到完整的外连接,但即使如此,删除嵌套的内联视图也可能会有所不同。

或者它可能不会;我不能在我可用的任何数据库版本中产生错误,所以我无法检查这是否可以避免它。你必须做一些测试和实验。如果你把它归结为最简单的形式你可以对你的数据和规则有意义,而你仍然会收到错误,你必须得到Oracle的帮助。