Chinaunix首页 | 论坛 | 博客
  • 博客访问: 187288
  • 博文数量: 18
  • 博客积分: 543
  • 博客等级: 下士
  • 技术积分: 265
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-31 16:06
文章分类

全部博文(18)

文章存档

2013年(2)

2012年(3)

2011年(13)

分类: Oracle

2011-09-08 11:00:30

版本如下:
SQL> select * from v$version;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
CORE    10.2.0.4.0      Production
TNS for Solaris: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production

简单说下现象。两表关联,结果可能不正确。语句大概如下:
select
    a.*
from
    table_a a,
    table_b b
where
    a.col1=b.col1

测试1:对该语句直接运行,结果正确。
测试2:对该语句增加并行hint /*+parallel (a 16)*/  结果不正确。

已通过甲方提交oracle support,后续跟进中。

===================================================

转一个 itpub 上搜索到的类似问题。不过对方版本为11g R2

http://www.itpub.net/thread-1360991-1-1.html
oracle 11gR2 并行查询返回错误结果的问题

Oracle 技术支持 - 2010年8月30日 上午10时16分31秒
Email To
----------------
,

Email Subject
--------------------------
SR #3-1949636655: CONV2TRAN:CHS procedure sql

Email Body
--------------------
Hello bo,

Please note that your Service Request Number 3-1949636655 has been updated. To view the update, please access My Oracle Support at and choose the Service Requests tab.

Regards,
Bin Gao, Oracle Customer Support

Note: Please do not reply to this email. This mailbox does not allow incoming messages.

Oracle 技术支持 - 2010年8月30日 上午10时16分13秒
=== ODM Action Plan ===
您好,周先生

感谢您的更新并且对我们的延迟表示抱歉。


工程师已经作了很多研究,但是找不到任何已知的问题或bug与这个问题相同。
工程师需要为这个问题创建一个新的bug,因此工程师需要以下信息:

行动计划:
============
a. 设置PARALLEL_DEGREE_POLICY 为 ‘Manual’ 之后查看问题是否能够重现。
b. 请提供一个小的,单独的,可重现的测试案例。



测试案例
========
一个单独的测试案例应包含如下内容:
1。列出所有相关的表和视图。
2。所有重现问题所需要的相关的用户对象的导出文件,导出文件应包含产生错误结果所需的数据。请不要上传全库的导出文件,
另外请使用exp 而不要使用expdp.
3。导出文件应包含和生产环境相同的所有统计信息,以便能产生相同的执行计划。
4。数据库初始化参数文件。(如果没有可以使用语句“create pfile from spfile”创建)
5。提供如何使用上传的文件来重现问题的详细步骤说明。如果没有这个说明,将会使您的测试案例被严重的拖延。
说明中应包括使用的数据库用户名,产生导出文件的用户名,导入时的顺序、连接数据库的用户名,以及为重现问题所需要
创建的额外对象的sql语句或pl/sql程序。权限或者角色的设定是不需要的,因为工程师会把所有测试案例中用到的用户赋予
dba角色。详细步骤说明应该由重现问题所需要的,可以直接拷贝/粘贴并运行的操作系统和sql语句构成。

一个单独的测试案例提供的导出文件,可以直接导入到一个空的包含所有重现问题所需的组件的数据库,并且能够重现问题。

工程师认为您一共提供了所需的大部分信息,除了一个包含详细步骤的说明文档。请在您的测试环境下测试成功后,将测试案例上传。

谢谢。

Oracle 技术支持 - 2010年8月23日 下午05时29分15秒
Email To
----------------
,

Email Subject
--------------------------
SR #3-1949636655: procedure sql

Email Body
--------------------
您好 周先生:

我们已经把您的更新上传给工程师,请耐心等待工程师的回复。

Regards,
Bin Gao, Oracle Customer Support

Note: Please do not reply to this email. This mailbox does not allow incoming messages.

 - 2010年8月23日 下午04时37分52秒
你好,感谢工程师给出的结论:不建议使用表的默认并行度,应该明确指定并行度。但是我在使用过程中发现只要把表的并行度设置 为超过4时候,计算数据结果就出错,环境还是之前的环境。我想这是不是跟oracle 有关系,或者是说碰到了bug呢。因为我的 主机有16颗CPU,总不能空着CPU不使用吧!我想了解这个问题的根本原因。

Oracle 技术支持 - 2010年8月18日 下午03时30分45秒
Email To
----------------
,

Email Subject
--------------------------
SR #3-1949636655: procedure sql

Email Body
--------------------
Hello bo,

Please note that your Service Request Number 3-1949636655 has been updated. To view the update, please access My Oracle Support at and choose the Service Requests tab.

Regards,
Bin Gao, Oracle Customer Support

Note: Please do not reply to this email. This mailbox does not allow incoming messages.

Oracle 技术支持 - 2010年8月18日 下午03时30分31秒
Generic Note
------------------------
您好 周先生, 谢谢您的更新。 否常高兴知道当并行度等于2的时候查询返回正确的结果。

默认的并行度算法是按照使用最大限度的资源设计的并且假设当使用更多的资源时操作可以更快的结束。
默认的并行机制指向单用户负载。在多用户环境下。默认的并行机制是不推荐的。

建议根据表的数据量多少设施并行度,而不是使用默认值, 使用默认值回到是大量的附属并行进程产生和数据偏移。
最后倒是错误的查询结果。

如果您有任何问题,请更新SR。

谢谢!

Oracle 技术支持 - 2010年8月17日 下午01时00分36秒
Email To
----------------
,

Email Subject
--------------------------
SR #3-1949636655: procedure sql

Email Body
--------------------
您好 周先生:

我们已经把您的更新上传给工程师,请耐心等待工程师的回复。

Regards,
Bin Gao, Oracle Customer Support

Note: Please do not reply to this email. This mailbox does not allow incoming messages.

 - 2010年8月17日 上午11时12分42秒
Uploaded Attachment sp_insert_dw_wl_user_act_30_t_parallel_2.TXT in GTCR

Oracle 技术支持 - 2010年8月17日 上午11时12分38秒
Virus scan completed for file sp_insert_dw_wl_user_act_30_t_parallel_2.TXT

 - 2010年8月17日 上午11时11分58秒
你好,附件是按工程师要求将两个表并行度设置为2以后产生的执行计划,存储过程执行的结果是正确的。另外,我认为这个事情持续了好长时间,每次我都在帮你们做测试工作,希望工程师哪边可以独立解决问题,或者提升等级。

Oracle 技术支持 - 2010年8月17日 上午08时36分47秒
Email To
----------------
,

Email Subject
--------------------------
SR #3-1949636655: procedure sql

Email Body
--------------------
Hello bo,

Please note that your Service Request Number 3-1949636655 has been updated. To view the update, please access My Oracle Support at and choose the Service Requests tab.

Regards,
Bin Gao, Oracle Customer Support

Note: Please do not reply to this email. This mailbox does not allow incoming messages.

Oracle 技术支持 - 2010年8月17日 上午08时36分00秒
Generic Note
------------------------
您好 周先生,

感谢您的更新。

非常高兴听到把表的并行度设置成1之后能返回正确的结果。 请尝试下面的操作,并查看其结果。

1.将下面的表的并行度改称2
SQL>alter table T_DW_WL_ACCOUNT_STATUS_DAY parallel 2;
SQL>alter table T_DW_WL_ACCOUNT_STATUS parallel 2;

2。执行下面的查询,观察是否产生错误的结果。
SQL>exec sp_insert_dw_wl_user_act_30_t('20100701',:a,:b);
SQL>select * from t_st_active_user_30_new;

请搜集上面2个查询的执行计划并上传。


谢谢

Oracle 技术支持 - 2010年8月16日 下午03时21分10秒
Email To
----------------
,

Email Subject
--------------------------
SR #3-1949636655: procedure sql

Email Body
--------------------
您好 周先生:

我们已经把您的更新上传给工程师,请耐心等待工程师的回复。

Regards,
Bin Gao, Oracle Customer Support

Note: Please do not reply to this email. This mailbox does not allow incoming messages.

 - 2010年8月16日 上午10时04分26秒
Uploaded Attachment sp_insert_dw_wl_user_act_30_t.txt in GTCR

Oracle 技术支持 - 2010年8月16日 上午10时04分23秒
Virus scan completed for file sp_insert_dw_wl_user_act_30_t.txt

 - 2010年8月16日 上午10时03分28秒
你好,现在上传附件为 禁用 表级并行后产生的执行计划,执行查询的结果是完全正确的(T_DW_WL_ACCOUNT_STATUS_DAY、T_DW_WL_ACCOUNT_STATUS)。

Oracle 技术支持 - 2010年8月13日 下午01时41分50秒
Email To
----------------
,

Email Subject
--------------------------
SR #3-1949636655: procedure sql

Email Body
--------------------
Hello bo,

Please note that your Service Request Number 3-1949636655 has been updated. To view the update, please access My Oracle Support at and choose the Service Requests tab.

Regards,
Bin Gao, Oracle Customer Support

Note: Please do not reply to this email. This mailbox does not allow incoming messages.

Oracle 技术支持 - 2010年8月13日 下午01时41分25秒
Generic Note
------------------------
UPDATE FROM ENGINEER
-------------------------------------
你好, 周先生.

请执行下面的操作。
1。SQL>alter table T_DW_WL_ACCOUNT_STATUS_DAY noparallel;
SQL>alter table T_DW_WL_ACCOUNT_STATUS noparallel;

2.运行存储过程,察看错误的结果是否仍然出现。
SQL>exec sp_insert_dw_wl_user_act_30_t('20100701',:a,:b);
SQL>select * from t_st_active_user_30_new;

3. 请搜集步骤2中执行的语句的执行计划并上传,以便进行进一步的分析。

谢谢。

Oracle 技术支持 - 2010年8月11日 下午01时20分10秒
Email To
----------------
,

Email Subject
--------------------------
SR #3-1949636655: procedure sql

Email Body
--------------------
您好 周先生:

我们已经把您的更新上传给工程师,请耐心等待工程师的回复。

Regards,
Bin Gao, Oracle Customer Support

Note: Please do not reply to this email. This mailbox does not allow incoming messages.

 - 2010年8月10日 下午05时04分55秒
Uploaded Attachment parallel_execute_plan in GTCR

Oracle 技术支持 - 2010年8月10日 下午05时04分52秒
Virus scan completed for file parallel_execute_plan

 - 2010年8月10日 下午05时00分56秒
Uploaded Attachment noparallel_execute_plan in GTCR

Oracle 技术支持 - 2010年8月10日 下午05时00分53秒
Virus scan completed for file noparallel_execute_plan

 - 2010年8月10日 下午04时59分58秒
你好,现在按工程师要求上传两个附件:parallel_execute_plan (启用并行产生的执行计划), noparallel_execute_plan(禁用并行产生的执行计划)。

Oracle 技术支持 - 2010年8月10日 上午10时37分04秒
Email To
----------------
,

Email Subject
--------------------------
SR #3-1949636655: procedure sql

Email Body
--------------------
Hello bo,

Please note that your Service Request Number 3-1949636655 has been updated. To view the update, please access My Oracle Support at and choose the Service Requests tab.

Regards,
Bin Gao, Oracle Customer Support

Note: Please do not reply to this email. This mailbox does not allow incoming messages.




Oracle 技术支持 - 2010年8月10日 上午10时36分51秒
=== ODM Action Plan ===
您好 :周先生,

感谢您的更新。
工程师需要文件sp_insert_dw_wl_user_act_30_t(有distinct的那一个)中查询语句的执行计划。请将启用了并行查询(产生错误的结果)和未启用
并行查询(产生正确的结果)时的执行计划都上传。

另外,请提供查询中涉及到的对象的并行度。


谢谢。

Oracle 技术支持 - 2010年8月9日 上午10时20分44秒
Email To
----------------
,

Email Subject
--------------------------
SR #3-1949636655: procedure sql

Email Body
--------------------
您好 周先生:

我们已经把您的更新上传给工程师,请耐心等待工程师的回复。

Regards,
Bin Gao, Oracle Customer Support

Note: Please do not reply to this email. This mailbox does not allow incoming messages.

 - 2010年8月9日 上午10时14分00秒
你好,存储过程sp_insert_dw_wl_user_act_30_t(即带distinct 的存储过程)当使用并行查询时候,没有产生过正确结果,但不启用并行查询时候产生的结果是正确的。谢谢

Oracle 技术支持 - 2010年8月9日 上午10时07分52秒
Email To
----------------
,

Email Subject
--------------------------
SR #3-1949636655: procedure sql

Email Body
--------------------
Hello bo,

Please note that your Service Request Number 3-1949636655 has been updated. To view the update, please access My Oracle Support at and choose the Service Requests tab.

Regards,
Bin Gao, Oracle Customer Support

Note: Please do not reply to this email. This mailbox does not allow incoming messages.

Oracle 技术支持 - 2010年8月9日 上午10时07分20秒
=== ODM Action Plan ===
周先生,您好:

工程师看过上传的存储过程后,发现在存储过程sp_insert_dw_wl_user_act_30_t中加入了'distinct',之后产生了错误的结果。
存储过程sp_insert_dw_wl_user_act_30_t是否产生过正确的结果?当产生正确结果时,并行查询是否被起用。

谢谢。

Oracle 技术支持 - 2010年8月6日 上午09时04分01秒
Email To
----------------
,

Email Subject
--------------------------
SR #3-1949636655: procedure sql

Email Body
--------------------
您好 周先生:

我们已经把您的更新和文件上传给工程师,请耐心等待工程师的回复。


谢谢。
Bin Gao, Oracle Customer Support

Note: Please do not reply to this email. This mailbox does not allow incoming messages.

 - 2010年8月5日 下午06时37分08秒
Uploaded Attachment sqlplus_sql_explain_plan in GTCR

Oracle 技术支持 - 2010年8月5日 下午06时37分05秒
Virus scan completed for file sqlplus_sql_explain_plan

 - 2010年8月5日 下午06时36分48秒
Uploaded Attachment sp_insert_dw_wl_user_act_30_t_exec_plan in GTCR

Oracle 技术支持 - 2010年8月5日 下午06时36分45秒
Virus scan completed for file sp_insert_dw_wl_user_act_30_t_exec_plan

 - 2010年8月5日 下午06时36分35秒
Uploaded Attachment sp_insert_dw_wl_user_act_30_o_exec_plan in GTCR

Oracle 技术支持 - 2010年8月5日 下午06时36分32秒
Virus scan completed for file sp_insert_dw_wl_user_act_30_o_exec_plan

 - 2010年8月5日 下午06时36分12秒
Uploaded Attachment procedure_sp_insert_dw_wl_user_act_30_t in GTCR

Oracle 技术支持 - 2010年8月5日 下午06时36分09秒
Virus scan completed for file procedure_sp_insert_dw_wl_user_act_30_t

 - 2010年8月5日 下午06时35分36秒
Uploaded Attachment procedure_sp_insert_dw_wl_user_act_30_o in GTCR

Oracle 技术支持 - 2010年8月5日 下午06时35分33秒
Virus scan completed for file procedure_sp_insert_dw_wl_user_act_30_o

 - 2010年8月5日 下午06时35分01秒
Uploaded Attachment note_readme.txt in GTCR

Oracle 技术支持 - 2010年8月5日 下午06时34分58秒
Virus scan completed for file note_readme.txt

 - 2010年8月5日 下午06时34分03秒
Uploaded Attachment execute_procedure_result.txt in GTCR

Oracle 技术支持 - 2010年8月5日 下午06时34分00秒
Virus scan completed for file execute_procedure_result.txt

 - 2010年8月5日 下午06时32分50秒
Uploaded Attachment procedure_sp_insert_dw_wl_user_act_30_o_10046_trace.zip in GTCR

Oracle 技术支持 - 2010年8月5日 下午06时32分40秒
Virus scan completed for file procedure_sp_insert_dw_wl_user_act_30_o_10046_trace.zip

 - 2010年8月5日 下午06时11分06秒
Uploaded Attachment procedure_sp_insert_dw_wl_user_act_30_t_10046_trace.zip in GTCR

Oracle 技术支持 - 2010年8月5日 下午06时11分02秒
Virus scan completed for file procedure_sp_insert_dw_wl_user_act_30_t_10046_trace.zip

 - 2010年8月5日 下午06时07分54秒
你好,现按照工程师要求重新提交了所需要文件,所提交文件说明:

提供信息如下:

1. 查询语句--请在一个单独的文本文件中提供。

Answer:查询语句存储过程见附件 sp_insert_dw_wl_user_act_30_o(计算结果正确) 和存储过程sp_insert_dw_wl_user_act_30_t(计算结果错误)

2。那种类型的错误结果存在?多余行/务数据返回/返回数据少?

Answer:执行存储过程后计算的结果数据错误,不存在返回数据少行、多行现象(正常情况也是返回一行),只是计算结果不对。

3。这个查询之前时候能够获得正确的结果?做了什么样的修改之后问题开始出现?

Answer: 这两个存储过程内容几乎相同,只是差了一个 distinct 参数,加上distinct后 产生的结果就不正确。

4。查询涉及到的对象的并行度使多少?并行度可以通过下面的查询获得。
(select table_name, DEGREE from user_tables where table_name = '<< Your_table_name_in_uppercase>>';
select index_name, DEGREE from user_indexes where index_name = '<< Your_index_name_in_uppercase>>';
对所有查询调用的表和索引执行上面的查询)。

Answer:具体数值参见附件 execute procedure result.txt


5。请对有问题的查询语句收集10046跟踪文件。这样做的目的是找到执行计划中的哪一步导致了这个问题。如果可能的话,请将查询结果正确的语句的
10046 跟踪文件一起上传,以便进行比较。
alter session set tracefile_identifier='10046'
alter session set timed_statistics = true;
alter session set statistics_level=all;
alter session set max_dump_file_size = unlimited;
alter session set events '10046 trace name context forever,level 12';
-- run your SQL(s)--
select * from dual;
exit;

以上的步骤将在user_dump_dest路径下产生跟踪文件,请上传这个文件。


Answer:相关trace文件见附件 procedure sp_insert_dw_wl_user_act_30_o 10046 trace.zip 和 procedure sp_insert_dw_wl_user_act_30_t 10046 trace.zip


6。请提供查询语句在sql*plus下执行时的执行计划。如果可能的话,请将查询结果正确的语句的执行计划一起上传。
请参照下面的文档生成执行计划。
Note:235530.1 - Recommended Method for Obtaining a Formatted Explain Plan

注意:请确保被使用的plan_table是最新的。 如果可能请将有问题的和正确的查询语句的执行计划和10046跟踪文件一起上传,以便进行比较。

Answer: 两个存储过程的执行计划参见 附件 sp_insert_dw_wl_user_act_30_o exec plan 和 sp_insert_dw_wl_user_act_30_t exec plan

Sqlplus 产生的存储过程见附件 sqlplus sql explain plan

备注:

两个存储过程源码见附件 procedure sp_insert_dw_wl_user_act_30_t 和 procedure sp_insert_dw_wl_user_act_30_o

Oracle 技术支持 - 2010年8月5日 上午11时22分06秒
Generic Note
------------------------
ACTION PLAN
============
你好, 周先生

当诊断这类问题的时候,工程师需要了错误结果的具体情况(返回的行数不正确,还是返回的数据值错误), 是否问题是由于糟糕的执行计划造成的,还是
在运行时由于数据丢失或者数据损坏造成的。因此工程师需要了解优化器做出了什么样的决定以及原因,另外工程师需要查询运行时的跟踪文件,以便找出问题是在
执行计划的哪一步开始出现问题。 另外,能够知道如何产生正确的结果是非常有帮助的。产生正确结果时所作的任何步骤和细节对于缩小问题和快速找到问题的原因
都是有帮助的。

为了解决这个问题,请提供下面的信息:
1. 查询语句--请在一个单独的文本文件中提供。
2。那种类型的错误结果存在?多余行/务数据返回/返回数据少?
3。这个查询之前时候能够获得正确的结果?做了什么样的修改之后问题开始出现?
4。查询涉及到的对象的并行度使多少?并行度可以通过下面的查询获得。
select table_name, DEGREE from user_tables where table_name = '<< Your_table_name_in_uppercase>>';
select index_name, DEGREE from user_indexes where index_name = '<< Your_index_name_in_uppercase>>';

请对所有查询调用的表和索引执行上面的查询。

5。请对有问题的查询语句收集10046跟踪文件。这样做的目的是找到执行计划中的哪一步导致了这个问题。如果可能的话,请将查询结果正确的语句的
10046 跟踪文件一起上传,以便进行比较。
alter session set tracefile_identifier='10046'
alter session set timed_statistics = true;
alter session set statistics_level=all;
alter session set max_dump_file_size = unlimited;
alter session set events '10046 trace name context forever,level 12';
-- run your SQL(s)--
select * from dual;
exit;

以上的步骤将在user_dump_dest路径下产生跟踪文件,请上传这个文件。
如需更多信息,请查看下面的文档。
Note:376442.1 - Recommended Method for Obtaining 10046 trace for Tuning

6。请提供查询语句在sql*plus下执行时的执行计划。如果可能的话,请将查询结果正确的语句的执行计划一起上传。
请参照下面的文档生成执行计划。
Note:235530.1 - Recommended Method for Obtaining a Formatted Explain Plan

注意:请确保被使用的plan_table是最新的。 如果可能请将有问题的和正确的查询语句的执行计划和10046跟踪文件一起上传,以便进行比较。

谢谢。

Oracle 技术支持 - 2010年8月4日 上午10时58分33秒
Call - Outbound
------------------------------
CUSTOMER UPDATE
------------------------------
客户要求将这个服务请求提升为2级,因为这个问题对客户的影响很大,并转到与客户时区相近的工程师进行处理。

Thank you
Allen Gao
Global Customer Service.

 - 2010年8月4日 上午10时47分33秒
我的sql语法没有错误,逻辑也没有错误,为什么产生错误结果是正常的呢?
出现这种情况, 原因是我procedure写的不对,还是oracle数据库存在bug?
parallel_max_servers应该设置多少是合适的呢?才能不会出现这样的错误呢?

我们写PL/SQL不止一次出现这样的问题,多次出现sql查询查询不到正确的结果。
当然我们也都使用了parallel query。是不是说使用parallel就存在出现错误的可能?

我要求提升这个sr的等级!!!

Oracle 技术支持 - 2010年8月4日 上午09时04分35秒
Generic Note
------------------------
ACTION PLAN
============
工程师理解表中数据很多,但是SR中的各个存储过程之前关联表exp_status, 所以当运行的时候产生错误的结果是正常的。

所以,工程师建议修改存储过程来调用新的表和调用存储过程的命令,并测试执行查询时错误的数据是否出现。

另外,请降低参数parallel_max_servers的值,之后测试是否对问题有影响。

Oracle 技术支持 - 2010年8月3日 下午04时03分17秒
Generic Note
------------------------
已经将信息传给国外工程师。

Thanks,
Oracle Software Support

 - 2010年8月3日 上午10时22分13秒
Uploaded Attachment tab.zip in GTCR

Oracle 技术支持 - 2010年8月3日 上午10时22分10秒
Virus scan completed for file tab.zip

 - 2010年8月3日 上午10时20分25秒
Uploaded Attachment init.ora in GTCR

Oracle 技术支持 - 2010年8月3日 上午10时20分22秒
Virus scan completed for file init.ora

 - 2010年8月3日 上午10时19分44秒
1、exp_status的数据即是表t_dw_wl_account_status的数据,
exp_status_day的数据既是 t_dw_wl_account_status_day的数据。
由于原表数据巨大,所以只是抽取了部分数据。
已经上传了原表表导出文件
2、sql语句就是procedure中的sql。两个procedure之前都上传过了
3、parallel_max_servers=640 涉及表的degree都是default。

Oracle 技术支持 - 2010年8月3日 上午09时53分08秒
Email To
----------------
,

Email Subject
--------------------------
SR #3-1949636655: procedure sql

Email Body
--------------------
Hello bo,

Please note that your Service Request Number 3-1949636655 has been updated. To view the update, please access My Oracle Support at and choose the Service Requests tab.

Regards,
Bin Gao, Oracle Customer Support

Note: Please do not reply to this email. This mailbox does not allow incoming messages.

Oracle 技术支持 - 2010年8月3日 上午09时52分39秒
=== ODM Action Plan ===

Hi

在exp文件中,你使用了表exp_status_day, exp_status , 但是在存储过程中:

=============================================================
源表为:  t_dw_wl_account_status,  t_dw_wl_account_status_day
==============================================================

不知您是否能够提供一个exp文件包括存储过程中用到的所有表,以便于测试。
并且提供能够看到正确和错误数据的SQL语句。
请问您的参数parallel_max_servers 的值是什么,查询中涉及到的表的degree是多少?

Regards

Oracle 技术支持 - 2010年8月2日 下午03时11分00秒
Generic Note
------------------------
已经将信息传达给国外工程师。

Thanks,
Oracle Software Support

 - 2010年8月2日 下午02时20分31秒
你好,当使用了noparallel hint 后,只有trc1(只在子查询中使用了no_parallel hint)和 trc2(在子查询和主查询中都用了 no_parallel hint)的查询结果正确,trc3(只在主查询中用了 no_parallel hint)查询结果不正确。

Oracle 技术支持 - 2010年8月2日 上午11时28分16秒
Email To
----------------
,

Email Subject
--------------------------
SR #3-1949636655: procedure sql

Email Body
--------------------
Hello bo,

Please note that your Service Request Number 3-1949636655 has been updated. To view the update, please access My Oracle Support at and choose the Service Requests tab.

Regards,
Bin Gao, Oracle Customer Support

Note: Please do not reply to this email. This mailbox does not allow incoming messages.

Oracle 技术支持 - 2010年8月2日 上午11时27分50秒
Generic Note
------------------------

你好,

请说明一下在这3个实验中,加入hint后,是否得到了正确的结果?

Best Regards,
Li Xin
Oracle Software Support


 - 2010年7月30日 上午11时21分22秒
Uploaded Attachment trc3.zip in GTCR

Oracle 技术支持 - 2010年7月30日 上午11时21分17秒
Virus scan completed for file trc3.zip

 - 2010年7月30日 上午11时14分29秒
附件上传说明:
T_ST_ACTIVE_USER_30.txt 为存储过程中所需要的另外一张表(目标表的建表语句),其它两张表于前几日已上传。
trc1 文件是 在子查询中使用了no_parallel hint。
trc2 文件是 在子查询和主查询中都用了 no_parallel hint
trc3 文件是 在主查询中用了 no_parallel hint

其中trc1和trc2查询结果正常。trc3查询结果错误。

 - 2010年7月30日 上午10时43分10秒
Uploaded Attachment trc2.zip in GTCR

Oracle 技术支持 - 2010年7月30日 上午10时43分05秒
Virus scan completed for file trc2.zip

 - 2010年7月30日 上午10时39分08秒
Uploaded Attachment T_ST_ACTIVE_USER_30.txt in GTCR

Oracle 技术支持 - 2010年7月30日 上午10时39分06秒
Virus scan completed for file T_ST_ACTIVE_USER_30.txt

 - 2010年7月30日 上午10时38分20秒
Uploaded Attachment trc1.zip in GTCR

Oracle 技术支持 - 2010年7月30日 上午10时38分14秒
Virus scan completed for file trc1.zip

 - 2010年7月30日 上午10时31分42秒
Uploaded Attachment note.txt in GTCR

Oracle 技术支持 - 2010年7月30日 上午10时31分39秒
Virus scan completed for file note.txt

Oracle 技术支持 - 2010年7月30日 上午08时12分48秒
Email To
----------------
,

Email Subject
--------------------------
SR #3-1949636655: procedure sql

Email Body
--------------------
Hello bo,

Please note that your Service Request Number 3-1949636655 has been updated. To view the update, please access My Oracle Support at and choose the Service Requests tab.

Regards,
Bin Gao, Oracle Customer Support

Note: Please do not reply to this email. This mailbox does not allow incoming messages.

Oracle 技术支持 - 2010年7月30日 上午08时12分34秒
Generic Note
------------------------
您好,
请在查询语句中加上no_parallel的hint,以便观察hint对这个查询语句是否起作用。
/*+ no_parallel(table_alis) */

另外,上传的导出文件中只包含两个表的数据,请上传查询语句所使用的其他表的数据。

谢谢。

 - 2010年7月29日 下午12时09分00秒
Uploaded Attachment tables_data_exp.zip in GTCR

Oracle 技术支持 - 2010年7月29日 下午12时08分56秒
Virus scan completed for file tables_data_exp.zip

 - 2010年7月29日 上午11时08分56秒
Uploaded Attachment noparallel_sp_insert_dw_wl_user_act_30_trc.zip in GTCR

Oracle 技术支持 - 2010年7月29日 上午11时08分53秒
Virus scan completed for file noparallel_sp_insert_dw_wl_user_act_30_trc.zip

 - 2010年7月29日 上午11时08分28秒
Uploaded Attachment noparallel_sp_insert_dw_wl_user_act_30_t_trc.zip in GTCR

Oracle 技术支持 - 2010年7月29日 上午11时08分25秒
Virus scan completed for file noparallel_sp_insert_dw_wl_user_act_30_t_trc.zip

 - 2010年7月29日 上午11时05分35秒
按照工程师提示,当去掉并行后,运行跟原来同样存储过程后数据是一致的,没有出错,附件带有三个压缩文件,其中有两个是 禁用并行后产生的trace文件,另外一个为测试数据。请参考,谢谢!

Oracle 技术支持 - 2010年7月29日 上午08时31分25秒
=== ODM Action Plan ===
由于这个问题是查询结果中某个经过聚合函数操作后的列的值不同,所以没有一个测试例子是很难跟踪问题的。

根据已上传的跟踪文件,工程师发现这个查询语句启动了并行查询功能。

请将并行查询功能关闭,之后再运行一遍有问题的查询语句,看看是否起作用。

请使用下面的步骤进行测试
1.SQL> alter session disable parallel query;
2.SQL> <执行有问题的查询语句>

谢谢

 - 2010年7月27日 上午11时22分41秒
首先我们的环境不一样。可能测试的结果也不一样。其次我们的业务逻辑复杂,我给你的部分数据,可能造成无记录返回的结果。实在很不方便。可否我们协助你们采集你们所需要的信息? 现在我已经把10046 trace结果上传了,如果需要更多信息,我们会尽量帮助采集

Oracle 技术支持 - 2010年7月27日 上午08时21分56秒
Generic Note
------------------------
UPDATE
=======
工程师并不需要所有的10G数据,只需要其中的一部分数据,因为查询的结果只有1行数据。该问题是否可以通过表中的一小部分数据就可以重现?如果可以的话,只导出这部分数据就可以了。

谢谢。

 - 2010年7月26日 下午05时29分53秒
Uploaded Attachment sp_insert_dw_wl_user_act_30_trc.zip in GTCR

Oracle 技术支持 - 2010年7月26日 下午05时29分47秒
Virus scan completed for file sp_insert_dw_wl_user_act_30_trc.zip

 - 2010年7月26日 下午02时55分26秒
Uploaded Attachment sp_insert_dw_wl_user_act_30_t_trc.zip in GTCR

Oracle 技术支持 - 2010年7月26日 下午02时55分18秒
Virus scan completed for file sp_insert_dw_wl_user_act_30_t_trc.zip

 - 2010年7月26日 下午01时56分05秒
Uploaded Attachment sp_insert_dw_wl_user_act_30_trc.JPG in GTCR

Oracle 技术支持 - 2010年7月26日 下午01时56分02秒
Virus scan completed for file sp_insert_dw_wl_user_act_30_trc.JPG

 - 2010年7月26日 下午01时55分17秒
Uploaded Attachment sp_insert_dw_wl_user_act_30_t_trc.JPG in GTCR

Oracle 技术支持 - 2010年7月26日 下午01时55分14秒
Virus scan completed for file sp_insert_dw_wl_user_act_30_t_trc.JPG

 - 2010年7月26日 上午11时41分36秒
我们可以提供更详细的测试过程。但是由于这个sql涉及的表的数据量很大,有10G的数据量,上传表导出文件比较困难。可否使用其他的办法来测试?

Oracle 技术支持 - 2010年7月23日 上午08时53分02秒
Email To
----------------
,

Email Subject
--------------------------
SR #3-1949636655: procedure sql

Email Body
--------------------
Hello bo,

Please note that your Service Request Number 3-1949636655 has been updated. To view the update, please access My Oracle Support at and choose the Service Requests tab.

Regards,
Bin Gao, Oracle Customer Support

Note: Please do not reply to this email. This mailbox does not allow incoming messages.

Oracle 技术支持 - 2010年7月23日 上午08时52分53秒
=== ODM Action Plan ===
由于连个存储过程都只返回一行数据,所以请改为执行下面的步骤:

请提供一个测试过程,以便工程师能够在本地的测试服务器上重现这个问题。
请提供测试所需要的所有表的导出文件以及重现问题的查询和步骤。

谢谢。

Oracle 技术支持 - 2010年7月22日 下午05时30分10秒
Email To
----------------
,

Email Subject
--------------------------
SR #3-1949636655: procedure sql

Email Body
--------------------
Hello bo,

Please note that your Service Request Number 3-1949636655 has been updated. To view the update, please access My Oracle Support at and choose the Service Requests tab.

Regards,
Bin Gao, Oracle Customer Support

Note: Please do not reply to this email. This mailbox does not allow incoming messages.

Oracle 技术支持 - 2010年7月22日 下午05时29分51秒
=== ODM Action Plan ===
1. 请执行以下步骤,搜集2个存储过程的10046 跟踪文件。

1) In a NEW session, connect as the schema owner
2) alter session set statistics_level=ALL;
3) ALTER SESSION SET TIMED_STATISTICS = TRUE;
4) ALTER SESSION SET EVENTS '10046 trace name context forever, level 12';
5)

6) SELECT 'close the cursor' FROM DUAL;
7) ALTER SESSION SET EVENTS '10046 trace name context off';
8) EXIT your session
8) Find raw 10046 trace file in user_dump_destination.


Oracle 技术支持 - 2010年7月22日 下午03时55分55秒
=== ODM Issue Verification ===
Verified the issue by the following from customer's update:
The customer found the procdure sp_insert_dw_wl_user_act_30 always
return incorrect result. The procedure sp_insert_dw_wl_user_act_30_t can
return correct result.
The only different between the two
procedures are the procedure sp_insert_dw_wl_user_act_30_t has a
'distinct' in the query. The customer ensure that
the two queries 
should return same result, even they are not indentical, because the two
queries return same result when execute them in sqlplus.

Oracle 技术支持 - 2010年7月22日 下午03时52分31秒
=== ODM Issue Clarification ===

On : 11.2.0.1 version, RDBMS


Find a query return incorrect result.

EXPECTED BEHAVIOR
-----------------------
Expect the query should return correct result.

STEPS
-----------------------
The issue can be reproduced at will with the following steps:
1. SQL> exec sp_insert_dw_wl_user_act_30

BUSINESS IMPACT
-----------------------
The issue has the following business impact:
Due to this issue, the application can not work normally.

Oracle 技术支持 - 2010年7月22日 下午03时49分54秒
Name
--------
=== ODM Data Collection ===

=== ODM Data Collection ===


LOG FILE
--------------
sp_insert_dw_wl_user_act_30.TXT:
create or replace procedure sp_insert_dw_wl_user_act_30(data_date in varchar2, exec_num out number, exec_info out varchar2) is
......
from
(select count(case when b.userid is not null and c.userid is not null then 1 else null end) active_user_conti --1活跃用户持续
, count(b.userid) active_user ----2活跃用户
, count(case when a.first_logout_time >= start_time_tm and a.first_logout_time < end_time_tm then 1 else null end) new_user --3本期新增用户
......

+++++++++++++++++++
sp_insert_dw_wl_user_act_30_t.TXT
create or replace procedure sp_insert_dw_wl_user_act_30_t(data_date in varchar2, exec_num out number, exec_info out varchar2) is
......
(select count(case when b.userid is not null and c.userid is not null then 1 else null end) active_user_conti --1活跃用户持续
, count(distinct b.userid) active_user ----2活跃用户 <==== the distinct was being used.
......


SCREEN SHOT
-----------------
sp_insert_dw_wl_user_act_30.JPG:
the screenshot shows the incorrect result.

sp_insert_dw_wl_user_act_30_t.JPG:
the screenshot shows the correct result.


FileName
----------------


FileComment
----------------------


Oracle 技术支持 - 2010年7月22日 下午03时29分43秒
Call - Outbound
------------------------------
Called customer and got the following:
1. The customer found the procdure sp_insert_dw_wl_user_act_30 always return incorrect result. The procedure sp_insert_dw_wl_user_act_30_t can return correct result.
The only different between the two procedures are the procedure sp_insert_dw_wl_user_act_30_t has a 'distinct' in the query. The customer ensure that
the two queries  should return same result, even they are not indentical, because the two queries return same result when execute them in sqlplus.

2.The uploaded screenshot sp_insert_dw_wl_user_act_30.JPG shows the incorrect result and the other one shows the correct result.

Thank you
Allen Gao
Global Customer Service.

 - 2010年7月22日 上午11时54分16秒
请尽快与我联系

 - 2010年7月21日 下午05时35分35秒
Uploaded Attachment oracle_sr.zip in GTCR

Oracle 技术支持 - 2010年7月21日 下午05时35分29秒
Virus scan completed for file oracle_sr.zip

Oracle 技术支持 - 2010年7月21日 下午04时11分12秒
Generic Note
------------------------
Hi Bo,

Thank you for using MetaLink. We are currently reviewing/researching the situation and will update
the Service Request (SR) or call you as soon as we have relevant information. Thank you for your
patience.

Best Regards,
Allen Gao(高 斌)
Global Customer Services

 - 2010年7月21日 下午03时05分01秒
问题说明: procedure 中的sql查询结果不正确

 - 2010年7月21日 下午03时05分01秒

### New or existing code ###
New Code.
### Please provide a detailed description of your problem. ###
### Error numbers and error messages: ###
### Used to work ###
no
### What changed ###
### Code causing the failure ###
是否可以轻松地从该问题中恢复, 绕开或解决该问题?

出现问题后, 系统或应用程序是否继续正常工作?

是否系统或应用程序的标准功能仍然可用, 服务少量丢失?




--the procedure execute result is wrong

create or replace procedure sp_insert_dw_wl_user_act_30_t(data_date in varchar2, exec_num out number, exec_info out varchar2) is
    v_ttime         date;
    end_time_tm     date;
    start_time_tm   date;
    start_time_lm   date;

    day_cycle       number :=30;
    expend_num      number :=1000;
    online_time     number :=86400;
    gm_id      number(4) := 2;   --_wl;

    v_active_user_conti            number :=100;
    v_active_user                  number :=100;
    v_new_user                     number :=100;
    v_active_user_back             number :=100;
    v_active_user_lost             number :=100;
    v_conti_active_user_lost       number :=100;
    v_back_user_lost               number :=100;
    v_new_user_lost                number :=100;
    v_high_active_user_conti       number :=100;
    v_high_active_user             number :=100;
    v_high_active_new_user         number :=100;
    v_high_active_user_back        number :=100;
    v_high_active_user_lost        number :=100;
    v_conti_high_active_user_lost  number :=100;
    v_back_high_active_user_lost   number :=100;
    v_new_high_user_lost           number :=100;

begin

    v_ttime := to_date(data_date, 'yyyy-mm-dd');
    end_time_tm := v_ttime + 1;
    start_time_tm := v_ttime + 1 - day_cycle;
    start_time_lm := v_ttime + 1 - day_cycle - day_cycle;


    select
            active_user_conti
          , active_user
          , new_user
          , active_user_back
          , active_user_lost
          , conti_active_user_lost
          , back_user_lost
          , new_user_lost
          , high_active_user_conti
          , high_active_user
          , high_active_new_user
          , high_active_user_back
          , high_active_user_lost
          , conti_high_active_user_lost
          , back_high_active_user_lost
          , new_high_user_lost
    into
            v_active_user_conti
          , v_active_user
          , v_new_user
          , v_active_user_back
          , v_active_user_lost
          , v_conti_active_user_lost
          , v_back_user_lost
          , v_new_user_lost
          , v_high_active_user_conti
          , v_high_active_user
          , v_high_active_new_user
          , v_high_active_user_back
          , v_high_active_user_lost
          , v_conti_high_active_user_lost
          , v_back_high_active_user_lost
          , v_new_high_user_lost

    from
        (select   count(case when b.userid is not null and c.userid is not null then 1 else null end) active_user_conti
                , count(distinct b.userid)  active_user    -----------(this subquery is different from procedure sp_insert_dw_wl_user_act_30_o)
                , count(case when a.first_logout_time  >= start_time_tm and  a.first_logout_time  <  end_time_tm then 1 else null end)  new_user
                , count(case when (c.userid is null and b.userid is not null and a.first_logout_time  <  start_time_tm) then 1 else null end) active_user_back
                , count(case when c.userid is not null and b.userid is null then 1 else null end)  active_user_lost
                , count(case when d.userid is not null and c.userid is not null and b.userid is null then 1 else null end) conti_active_user_lost
                , count(case when d.userid is null and c.userid is not null and a.first_logout_time < start_time_lm and b.userid is null then 1 else null end) back_user_lost
                , count(case when b.userid is null and a.first_logout_time  >= start_time_lm and  a.first_logout_time  <  start_time_tm then 1 else null end)  new_user_lost
          from
                   t_dw_wl_account_status a,
                  (select   userid, sum(onlinetime) onlinetime
                   from     t_dw_wl_account_status_day
                   where    logtime >= start_time_tm
                   and      logtime <  end_time_tm
                   and      account is not null
                   group by userid) b,
                  (select   userid, sum(onlinetime) onlinetime
                   from     t_dw_wl_account_status_day
                   where    logtime >= start_time_lm
                   and      logtime <  start_time_tm
                   and      account is not null
                   group by userid) c,
                  (select   userid, sum(onlinetime) onlinetime
                   from     t_dw_wl_account_status_day
                   where    logtime >= start_time_lm - day_cycle
                   and      logtime <  start_time_lm
                   and      account is not null
                   group by userid) d
          where  a.userid = b.userid(+)
          and    a.userid = c.userid(+)
          and    a.userid = d.userid(+)),

         (select  count(case when b.userid is not null and c.userid is not null then 1 else null end) high_active_user_conti
                , count(distinct b.userid)  high_active_user
                , count(case when a.first_logout_time  >= start_time_tm and  a.first_logout_time  <  end_time_tm and b.userid is not null then 1 else null end)  high_active_new_user
                , count(case when b.userid is not null and c.userid is null and a.first_logout_time  <  start_time_tm then 1 else null end) high_active_user_back
                , count(case when b.userid is null and c.userid is not null then 1 else null end)  high_active_user_lost
                , count(case when d.userid is not null and c.userid is not null and b.userid is null then 1 else null end)  conti_high_active_user_lost
                , count(case when d.userid is null and c.userid is not null and a.first_logout_time < start_time_lm and b.userid is null then 1 else null end) back_high_active_user_lost
                , count(case when b.userid is null and c.userid is not null and a.first_logout_time  >= start_time_lm and  a.first_logout_time  <  start_time_tm then 1 else null end)  new_high_user_lost
          from
                   t_dw_wl_account_status a,
                  (select   userid, sum(onlinetime) onlinetime, sum(expend) expend
                   from     t_dw_wl_account_status_day
                   where    logtime >= start_time_tm
                   and      logtime <  end_time_tm
                   group by userid
                   having   sum(onlinetime) > online_time or sum(expend) > expend_num) b,
                  (select   userid, sum(onlinetime) onlinetime, sum(expend) expend
                   from     t_dw_wl_account_status_day
                   where    logtime >= start_time_lm
                   and      logtime <  start_time_tm
                   group by userid
                   having   sum(onlinetime) > online_time or sum(expend) > expend_num) c,
                  (select   userid, sum(onlinetime) onlinetime, sum(expend) expend
                   from     t_dw_wl_account_status_day
                   where    logtime >= start_time_lm - day_cycle
                   and      logtime <  start_time_lm
                   group by userid
                   having   sum(onlinetime) > online_time or sum(expend) > expend_num) d
          where  a.userid = b.userid(+)
          and    a.userid = c.userid(+)
          and    a.userid = d.userid(+));


    delete from t_st_active_user_30_new  where logtime = v_ttime and game_id = gm_id;
    insert into  t_st_active_user_30_new( logtime
                                   , game_id
                                   , active_user_conti
                                   , active_user
                                   , new_user
                                   , active_user_back
                                   , active_user_lost
                                   , conti_active_user_lost
                                   , back_user_lost
                                   , new_user_lost
                                   , high_active_user_conti
                                   , high_active_user
                                   , high_active_new_user
                                   , high_active_user_back
                                   , high_active_user_lost
                                   , conti_high_active_user_lost
                                   , back_high_active_user_lost
                                   , new_high_user_lost)
       values(v_ttime
            , gm_id
            , v_active_user_conti
            , v_active_user
            , v_new_user
            , v_active_user_back
            , v_active_user_lost
            , v_conti_active_user_lost
            , v_back_user_lost
            , v_new_user_lost
            , v_high_active_user_conti
            , v_high_active_user
            , v_high_active_new_user
            , v_high_active_user_back
            , v_high_active_user_lost
            , v_conti_high_active_user_lost
            , v_back_high_active_user_lost
            , v_new_high_user_lost);
    commit;

    exec_num := 7100;
    exec_info := 'Procedure sp_insert_dw_wl_user_act_30_t has runned successfully!';

EXCEPTION
  WHEN OTHERS THEN
    exec_num := 8100;
    exec_info := substr(SQLERRM, 1, 200);
end;




--the procedure execute result is right

create or replace procedure sp_insert_dw_wl_user_act_30_o(data_date in varchar2, exec_num out number, exec_info out varchar2) is
    v_ttime         date;
    end_time_tm     date;
    start_time_tm   date;
    start_time_lm   date;

    day_cycle       number :=30;
    expend_num      number :=1000;
    online_time     number :=86400;
    gm_id      number(4) := 2; 

    v_active_user_conti            number :=100;
    v_active_user                  number :=100;
    v_new_user                     number :=100;
    v_active_user_back             number :=100;
    v_active_user_lost             number :=100;
    v_conti_active_user_lost       number :=100;
    v_back_user_lost               number :=100;
    v_new_user_lost                number :=100;
    v_high_active_user_conti       number :=100;
    v_high_active_user             number :=100;
    v_high_active_new_user         number :=100;
    v_high_active_user_back        number :=100;
    v_high_active_user_lost        number :=100;
    v_conti_high_active_user_lost  number :=100;
    v_back_high_active_user_lost   number :=100;
    v_new_high_user_lost           number :=100;

begin

    v_ttime := to_date(data_date, 'yyyy-mm-dd');
    end_time_tm := v_ttime + 1;
    start_time_tm := v_ttime + 1 - day_cycle;
    start_time_lm := v_ttime + 1 - day_cycle - day_cycle;


    select
            active_user_conti
          , active_user
          , new_user
          , active_user_back
          , active_user_lost
          , conti_active_user_lost
          , back_user_lost
          , new_user_lost
          , high_active_user_conti
          , high_active_user
          , high_active_new_user
          , high_active_user_back
          , high_active_user_lost
          , conti_high_active_user_lost
          , back_high_active_user_lost
          , new_high_user_lost
    into
            v_active_user_conti
          , v_active_user
          , v_new_user
          , v_active_user_back
          , v_active_user_lost
          , v_conti_active_user_lost
          , v_back_user_lost
          , v_new_user_lost
          , v_high_active_user_conti
          , v_high_active_user
          , v_high_active_new_user
          , v_high_active_user_back
          , v_high_active_user_lost
          , v_conti_high_active_user_lost
          , v_back_high_active_user_lost
          , v_new_high_user_lost

    from
        (select   count(case when b.userid is not null and c.userid is not null then 1 else null end) active_user_conti
                , count(b.userid)  active_user         -----------(this subquery is different from procedure sp_insert_dw_wl_user_act_30_t)                , count(case when a.first_logout_time  >= start_time_tm and  a.first_logout_time  <  end_time_tm then 1 else null end)  new_user
                , count(case when (c.userid is null and b.userid is not null and a.first_logout_time  <  start_time_tm) then 1 else null end) active_user_back
                , count(case when c.userid is not null and b.userid is null then 1 else null end)  active_user_lost
                , count(case when d.userid is not null and c.userid is not null and b.userid is null then 1 else null end) conti_active_user_lost
                , count(case when d.userid is null and c.userid is not null and a.first_logout_time < start_time_lm and b.userid is null then 1 else null end) back_user_lost
                , count(case when b.userid is null and a.first_logout_time  >= start_time_lm and  a.first_logout_time  <  start_time_tm then 1 else null end)  new_user_lost
          from
                   t_dw_wl_account_status a,
                  (select   userid, sum(onlinetime) onlinetime
                   from     t_dw_wl_account_status_day
                   where    logtime >= start_time_tm
                   and      logtime <  end_time_tm
                   and      account is not null
                   group by userid) b,
                  (select   userid, sum(onlinetime) onlinetime
                   from     t_dw_wl_account_status_day
                   where    logtime >= start_time_lm
                   and      logtime <  start_time_tm
                   and      account is not null
                   group by userid) c,
                  (select   userid, sum(onlinetime) onlinetime
                   from     t_dw_wl_account_status_day
                   where    logtime >= start_time_lm - day_cycle
                   and      logtime <  start_time_lm
                   and      account is not null
                   group by userid) d
          where  a.userid = b.userid(+)
          and    a.userid = c.userid(+)
          and    a.userid = d.userid(+)),

         (select  count(case when b.userid is not null and c.userid is not null then 1 else null end) high_active_user_conti
                , count(distinct b.userid)  high_active_user
                , count(case when a.first_logout_time  >= start_time_tm and  a.first_logout_time  <  end_time_tm and b.userid is not null then 1 else null end)  high_active_new_user
                , count(case when b.userid is not null and c.userid is null and a.first_logout_time  <  start_time_tm then 1 else null end) high_active_user_back
                , count(case when b.userid is null and c.userid is not null then 1 else null end)  high_active_user_lost
                , count(case when d.userid is not null and c.userid is not null and b.userid is null then 1 else null end)  conti_high_active_user_lost
                , count(case when d.userid is null and c.userid is not null and a.first_logout_time < start_time_lm and b.userid is null then 1 else null end) back_high_active_user_lost
                , count(case when b.userid is null and c.userid is not null and a.first_logout_time  >= start_time_lm and  a.first_logout_time  <  start_time_tm then 1 else null end)  new_high_user_lost
          from
                   t_dw_wl_account_status a,
                  (select   userid, sum(onlinetime) onlinetime, sum(expend) expend
                   from     t_dw_wl_account_status_day
                   where    logtime >= start_time_tm
                   and      logtime <  end_time_tm
                   group by userid
                   having   sum(onlinetime) > online_time or sum(expend) > expend_num) b,
                  (select   userid, sum(onlinetime) onlinetime, sum(expend) expend
                   from     t_dw_wl_account_status_day
                   where    logtime >= start_time_lm
                   and      logtime <  start_time_tm
                   group by userid
                   having   sum(onlinetime) > online_time or sum(expend) > expend_num) c,
                  (select   userid, sum(onlinetime) onlinetime, sum(expend) expend
                   from     t_dw_wl_account_status_day
                   where    logtime >= start_time_lm - day_cycle
                   and      logtime <  start_time_lm
                   group by userid
                   having   sum(onlinetime) > online_time or sum(expend) > expend_num) d
          where  a.userid = b.userid(+)
          and    a.userid = c.userid(+)
          and    a.userid = d.userid(+));


    delete from t_st_active_user_30_new  where logtime = v_ttime and game_id = gm_id;
    insert into  t_st_active_user_30_new( logtime
                                   , game_id
                                   , active_user_conti
                                   , active_user
                                   , new_user
                                   , active_user_back
                                   , active_user_lost
                                   , conti_active_user_lost
                                   , back_user_lost
                                   , new_user_lost
                                   , high_active_user_conti
                                   , high_active_user
                                   , high_active_new_user
                                   , high_active_user_back
                                   , high_active_user_lost
                                   , conti_high_active_user_lost
                                   , back_high_active_user_lost
                                   , new_high_user_lost)
       values(v_ttime
            , gm_id
            , v_active_user_conti
            , v_active_user
            , v_new_user
            , v_active_user_back
            , v_active_user_lost
            , v_conti_active_user_lost
            , v_back_user_lost
            , v_new_user_lost
            , v_high_active_user_conti
            , v_high_active_user
            , v_high_active_new_user
            , v_high_active_user_back
            , v_high_active_user_lost
            , v_conti_high_active_user_lost
            , v_back_high_active_user_lost
            , v_new_high_user_lost);
    commit;

    exec_num := 7100;
    exec_info := 'Procedure sp_insert_dw_wl_user_act_30_o has runned successfully!';

EXCEPTION
  WHEN OTHERS THEN
    exec_num := 8100;
    exec_info := substr(SQLERRM, 1, 200);
end;




阅读(3190) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~