在AIX上执行查询导致挂起

时间:2012-08-06 12:38:47

标签: sql windows oracle aix

我有一个在Windows和AIX上运行的服务器应用程序,当客户端应用程序连接到在Windows上运行的实例并执行向服务器端发送查询的报告时,一切正常,但是当客户端应用程序连接到在AIX上运行的服务器实例并执行向服务器端发送相同查询的同一报表,应用程序挂起。

经过调查,我发现查询导致挂起,因为我使用sqlplus直接从AIX上的命令行运行查询,并且它也挂起了。

我必须注意,数据库是在具有Windows Server的其他计算机上运行的Oracle。

我所说的查询是:

select z_name, s_date,
        n_count, f_count, m_count, s_count, d_count, a_count,
        (n_count + f_count + m_count + s_count + d_count + a_count) as d_total
from
(select z_name, s_date,
          nvl((select s_count from vReport S1 where S1.z_id = S.z_id and S1.s_date = S.s_date and s_app = 'NC'), 0) as n_c_count,
          nvl((select s_count from vReport S1 where S1.z_id = S.z_id and S1.s_date = S.s_date and s_app = 'FS'), 0) as f_s_count,
          nvl((select s_count from vReport S1 where S1.z_id = S.z_id and S1.s_date = S.s_date and s_app = 'MC'), 0) as m_c_count,
          nvl((select s_count from vReport S1 where S1.z_id = S.z_id and S1.s_date = S.s_date and s_app like 'SAA %'), 0) as s_c_count,
          nvl((select s_count from vReport S1 where S1.z_id = S.z_id and S1.s_date = S.s_date and s_app = 'DC'), 0) as d_c_count,
          nvl((select s_count from vReport S1 where S1.z_id = S.z_id and S1.s_date = S.s_date and s_app = 'SA'), 0) as a_c_count,
          nvl((select sum(s_count) from vReport S1 where S1.z_id = S.z_id), 0) as d_total
from rvReport S
where s_date between TO_DATE('2012-08-01 00:00:00','YYYY-MM-DD HH24:MI:SS') and  TO_DATE('2012-08-02 23:59:59','YYYY-MM-DD HH24:MI:SS')
and  z_id in (3,61,41,21) 
union 
select distinct z_name, SYSDATE,
          nvl((select sum(s_count) from vReport S1 where S1.z_id = S.z_id and s_app = 'NC' and s_date between TO_DATE('2012-08-01 00:00:00','YYYY-MM-DD HH24:MI:SS') and  TO_DATE('2012-08-02 23:59:59','YYYY-MM-DD HH24:MI:SS')), 0) as n_c_count,
          nvl((select sum(s_count) from vReport S1 where S1.z_id = S.z_id and s_app = 'FS' and s_date between TO_DATE('2012-08-01 00:00:00','YYYY-MM-DD HH24:MI:SS') and  TO_DATE('2012-08-02 23:59:59','YYYY-MM-DD HH24:MI:SS')), 0) as f_s_count,
          nvl((select sum(s_count) from vReport S1 where S1.z_id = S.z_id and s_app = 'MC' and s_date between TO_DATE('2012-08-01 00:00:00','YYYY-MM-DD HH24:MI:SS') and  TO_DATE('2012-08-02 23:59:59','YYYY-MM-DD HH24:MI:SS')), 0) as m_c_count,
          nvl((select sum(s_count) from vReport S1 where S1.z_id = S.z_id and s_app like 'SAA %' and s_date between TO_DATE('2012-08-01 00:00:00','YYYY-MM-DD HH24:MI:SS') and  TO_DATE('2012-08-02 23:59:59','YYYY-MM-DD HH24:MI:SS')), 0) as s_c_count,
          nvl((select sum(s_count) from vReport S1 where S1.z_id = S.z_id and s_app = 'DC' and s_date between TO_DATE('2012-08-01 00:00:00','YYYY-MM-DD HH24:MI:SS') and  TO_DATE('2012-08-02 23:59:59','YYYY-MM-DD HH24:MI:SS')), 0) as d_c_count,
          nvl((select sum(s_count) from vReport S1 where S1.z_id = S.z_id and s_app = 'SA' and s_date between TO_DATE('2012-08-01 00:00:00','YYYY-MM-DD HH24:MI:SS') and  TO_DATE('2012-08-02 23:59:59','YYYY-MM-DD HH24:MI:SS')), 0) as a_c_count,
          nvl((select sum(s_count) from vStats S1 where S1.z_id = S.zone_id  and s_date between TO_DATE('2012-08-01 00:00:00','YYYY-MM-DD HH24:MI:SS') and  TO_DATE('2012-08-02 23:59:59','YYYY-MM-DD HH24:MI:SS')), 0) as z_total
from rvReport S
where s_date between TO_DATE('2012-08-01 00:00:00','YYYY-MM-DD HH24:MI:SS') and  TO_DATE('2012-08-02 23:59:59','YYYY-MM-DD HH24:MI:SS')
and z_id in (3,61,41,21)
) STEMP

注意:我忘了说,如果删除了union之后的select语句中的条件“和(3,61,41,21)中的z_id”,那么查询将在AIX上执行并且不会挂起但会返回错误的数据。

0 个答案:

没有答案