Home » SQL & PL/SQL » SQL & PL/SQL » different results of sql query on different servers (with the same data) (see below)
icon5.gif  different results of sql query on different servers (with the same data) [message #635543] Tue, 31 March 2015 13:56 Go to next message
ecivgamer
Messages: 147
Registered: May 2011
Location: Ukraine
Senior Member
Hi all,

We noticed different results of sql query on different servers (with the same data). Please help to understand the reason why.
CREATE TABLE FLATBED.TMP3_FINAN_COST_CENTER
(
COMPANY_CODE VARCHAR2(2 BYTE)
);

CREATE TABLE FLATBED.TMP3_ORGANIZATIONS
(
COMPANY_CODE CHAR(2 BYTE)
);

BEGIN
INSERT INTO flatbed.TMP3_FINAN_COST_CENTER (COMPANY_CODE)
SELECT '00' AS COMPANY_CODE FROM DUAL;
COMMIT;
END;

BEGIN
INSERT INTO flatbed.tmp3_ORGANIZATIONS(COMPANY_CODE)
SELECT 'ZZ' AS COMPANY_CODE FROM DUAL;
COMMIT;
END;

select 1 AS T1
from flatbed.tmp3_ORGANIZATIONS org1,
flatbed.TMP3_FINAN_COST_CENTER fin1
where
fin1.COMPANY_CODE = '00'
AND org1.COMPANY_CODE = 'ZZ'
and
fin1.COMPANY_CODE =
CASE
WHEN (SELECT COUNT(*)
FROM flatbed.TMP3_FINAN_COST_CENTER this2
WHERE this2.COMPANY_CODE=org1.COMPANY_CODE)>0
THEN org1.COMPANY_CODE
ELSE '00'
END
AND ROWNUM = 1


We tried it on two servers:

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

result:
no rows selected.


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

result:
T1
----------
1
1 row selected.

What is the reason of different behavior?

( cross-post https://community.oracle.com/message/12984717#12984717 )
Re: different results of sql query on different servers (with the same data) [message #635544 is a reply to message #635543] Tue, 31 March 2015 14:20 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
post EXPLAIN PLAN from both systems
Re: different results of sql query on different servers (with the same data) [message #635546 is a reply to message #635543] Tue, 31 March 2015 14:41 Go to previous messageGo to next message
Michel Cadot
Messages: 68644
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

The result is the one in 11.2.0.4, so this means there was a bug in 11.2.0.2 which was fixed in 11.2.0.4.

Re: different results of sql query on different servers (with the same data) [message #635547 is a reply to message #635543] Tue, 31 March 2015 14:42 Go to previous message
EdStevens
Messages: 1376
Registered: September 2013
Senior Member
see https://community.oracle.com/thread/3695237
Previous Topic: JSON parsing?
Next Topic: how to get unmatched record from emp and dept tables
Goto Forum:
  


Current Time: Wed Apr 24 01:04:17 CDT 2024