使用ORDER BY子句查询视图时出现内部Oracle错误

时间:2012-03-16 19:33:28

标签: sql oracle oracle11g

这个让我难过,所以我想我会看到是否有其他人遇到过这个问题和/或知道解决方法。

我有以下SELECT声明:

SELECT * FROM TPM_VIEWSEARCH_EXPORT VS WHERE (PROJECTTYPEID IN (1))

这很好用,虽然这是一个非常慢的查询,返回大约3,000行。但是,我想订购结果。所以我试试:

SELECT * FROM TPM_VIEWSEARCH_EXPORT VS WHERE (PROJECTTYPEID IN (1)) ORDER BY PROJECTID, VERSIONID

当我这样做时,查询运行大约25秒,然后返回:

  

ORA-00600:内部错误代码,参数:[kokegPinLob1],[],[],   [],[],[],[],[],[],[],[],[]

我也可以将ORDER BY子句移动到视图定义本身,并获得相同的错误。令人讨厌的是这个repros只在我们的生产服务器上运行(在Linux上运行),而不在我在Windows上本地运行的开发服务器上。但是,它确实会在100%的时间内重现。

VIEW定义可能有问题,也可能无关紧要,但无论如何它都在这里:

CREATE VIEW TPM_VIEWSEARCH_EXPORT AS
   SELECT
      V.PROJECTID, V.VERSIONID, V.NAME, V.STAGEID, V.REQUESTTYPE, V.PRIORITY, V.HEALTH, V.TRAININGDELIVERYSTART, V.TRAININGDELIVERYEND, V.MEASUREMENTINFO, V.DESCRIPTION, V.BUSINESSSPONSORLEVELINVOLVE,
      P.INITIATIVEID, P.LEADERSHIPONLY, P.BUSINESSLAUNCHDATE, P.EXPECTEDBUSINESSRESULTS, P.PROJECTTYPEID,
      T.SHORTNAME as ProjectType,
      I.NAME as InitiativeName, 
      C.NAME as TrainingCategory,
      S.NAME as StageName,
      PTO.FIRSTNAME as PTOFirst, PTO.LASTNAME as PTOLast,
      STO.FIRSTNAME as STOFirst, STO.LASTNAME as STOLast,
      LTS.FIRSTNAME as LTSFirst, LTS.LASTNAME as LTSLast,
      R.FIRSTNAME as ReqFirst, R.LASTNAME as ReqLast,
      BS.FIRSTNAME as BSFirst, BS.LASTNAME as BSLast,
      (select WM_CONCAT(FIRSTNAME || ' ' || LASTNAME) from TPM_PROJECTVERSIONSME inner join TPM_USER USING (USERID) where PROJECTID=V.PROJECTID and VERSIONID=V.VERSIONID) as SME,
      (select WM_CONCAT(NAME) from TPM_PROJECTAREAS inner join TPM_AREAS USING (AREAID) where PROJECTID=V.PROJECTID) as Areas,
      (select WM_CONCAT(NAME) from TPM_PROJECTWORKGROUPS inner join TPM_WORKGROUPS USING (WORKGROUPID) where PROJECTID=V.PROJECTID) as Workgroups,
      (select WM_CONCAT(NAME) from TPM_PROJECTVERSIONSYSTEMS inner join TPM_SYSTEMS USING (SYSTEMID) where PROJECTID=V.PROJECTID and VERSIONID=V.VERSIONID) as Systems,
      (select WM_CONCAT(NAME) from TPM_PROJECTVERSIONTEAMS inner join TPM_DEVELOPMENTTEAMS USING (TEAMID) where PROJECTID=V.PROJECTID and VERSIONID=V.VERSIONID) as SupportingDevTeams
   FROM TPM_PROJECTVERSION V
   INNER JOIN TPM_PROJECT P ON P.PROJECTID = V.PROJECTID
   INNER JOIN TPM_PROJECTTYPES T ON T.PROJECTTYPEID = P.PROJECTTYPEID
   INNER JOIN TPM_INITIATIVES I ON I.INITIATIVEID = P.INITIATIVEID
   INNER JOIN TPM_PROJECTSTAGE S ON S.STAGEID = V.STAGEID
   INNER JOIN TPM_PROJECTCATEGORIES PC ON (PC.PROJECTID=V.PROJECTID)
   INNER JOIN TPM_TRAININGCATEGORIES C ON (C.CATEGORYID=PC.CATEGORYID)
   INNER JOIN TPM_USER R ON (V.REQUESTOR=R.USERID)
   INNER JOIN TPM_USER BS ON (V.BUSINESSSPONSOR=BS.USERID)
   LEFT JOIN TPM_USER PTO ON PTO.USERID = V.PRIMARYTRAININGOWNER
   LEFT JOIN TPM_USER STO ON (V.SECONDARYTRAININGOWNER=STO.USERID)
   LEFT JOIN TPM_USER LTS ON (V.LEADTRAININGSPONSOR=LTS.USERID)

运行生产服务器的DBA声称这是一个已知的Oracle错误,但是没有可用的补丁。这是否真的是Oracle错误,或者此问题是否与视图定义或数据库中的数据有关。

更新

Oracle版本(开发机器,有效):

Oracle Database 11g Express Edition Release 11.2.0.2.0 - Beta
PL/SQL Release 11.2.0.2.0 - Beta
CORE    11.2.0.2.0  Production
TNS for 32-bit Windows: Version 11.2.0.2.0 - Beta
NLSRTL Version 11.2.0.2.0 - Production

Oracle版本(生产):

TNS for Solaris: Version 11.2.0.2.0 - Production
PL/SQL Release 11.2.0.2.0 - Production
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
NLSRTL Version 11.2.0.2.0 - Production
CORE    11.2.0.2.0  Production

2 个答案:

答案 0 :(得分:2)

Justin Cave在评论中推荐的解决方案是切换到LISTAGG函数而不是WM_CONCAT。此方法不仅可以避免崩溃,还可以将查询速度从大约46分钟提高到大约30秒。更新的代码是:

  (select LISTAGG(LASTNAME || ', ' || FIRSTNAME, '; ') WITHIN GROUP (ORDER BY LASTNAME, FIRSTNAME) from TPM_PROJECTVERSIONSME inner join TPM_USER USING (USERID) where PROJECTID=V.PROJECTID and VERSIONID=V.VERSIONID) as SME,
  (select LISTAGG(NAME, '; ') WITHIN GROUP (ORDER BY NAME) from TPM_PROJECTAREAS inner join TPM_AREAS USING (AREAID) where PROJECTID=V.PROJECTID) as Areas,
  (select LISTAGG(NAME, '; ') WITHIN GROUP (ORDER BY NAME) from TPM_PROJECTWORKGROUPS inner join TPM_WORKGROUPS USING (WORKGROUPID) where PROJECTID=V.PROJECTID) as Workgroups,
  (select LISTAGG(NAME, '; ') WITHIN GROUP (ORDER BY NAME) from TPM_PROJECTVERSIONSYSTEMS inner join TPM_SYSTEMS USING (SYSTEMID) where PROJECTID=V.PROJECTID and VERSIONID=V.VERSIONID) as Systems,
  (select LISTAGG(NAME, '; ') WITHIN GROUP (ORDER BY NAME) from TPM_PROJECTVERSIONTEAMS inner join TPM_DEVELOPMENTTEAMS USING (TEAMID) where PROJECTID=V.PROJECTID and VERSIONID=V.VERSIONID) as SupportingDevTeams

答案 1 :(得分:0)

这是Oracle程序异常的通用内部错误号。它表示进程遇到了低级别的意外情况。此消息的原因包括:

超时

文件损坏

内存中的数据检查失败

硬件,内存或I / O错误

错误地恢复文件

第一个参数是内部消息编号。其他参数是各种数字,名称和字符串。这些数字可能会改变不同版本的Oracle之间的含义。

操作:收集以下信息后,将此错误报告给Oracle客户支持: