SUPPORT / SAMPLES & SAS NOTES
 

Support

Problem Note 48063: An incorrect query might be passed to the database when the query contains inner and outer joins within a subquery

DetailsHotfixAboutRate It

If an SQL procedure (PROC) query includes the following, an incomplete query might be submitted to the database management system (DBMS):

  • Multiple DBMS tables are being accessed via a LIBNAME engine
  • A DBMS table is subsetted with a subquery that contains both inner and outer joins with multiple DBMS tables
  • The subquery also contains a WHERE clause that further subsets the results of the join
The following example illustrates such a query:
Create Table results1 as SELECT table0.ID_NUMBER FROM dblib.table0 WHERE table0.ID_NUMBER in ( SELECT table0.ID_NUMBER FROM dblib.table1 INNER JOIN dblib.table2 ON (table1.ID_NUMBER = table2.ID_NUMBER) RIGHT OUTER JOIN dblib.table3 ON (table3.PROSPECT_ID = table2.PROSPECT_ID) INNER JOIN dblib.table4 ON (table4.PROSPECT_ID = table3.PROSPECT_ID) INNER JOIN dblib.table0 ON (table0.ID_NUMBER = table4.ID_NUMBER) WHERE table2.ACTIVE = 'Y' AND table2.TYPE IN ( 'PM', 'PT' ) );

The query that is submitted to the DBMS might be missing the WHERE conditions that existed in the original query. The lack of WHERE conditions might lead to more rows than would have been expected had the WHERE clause been included. This occurs because the extra rows are those that would not have met the condition(s) in the WHERE clause.

The code that is submitted might look like the following. (Note: This code has been reformatted for ease of reading.)

select TXT_1."ID_NUMBER" from TABLE0 TXT_1 where TXT_1."ID_NUMBER" in ( select TXT_6."ID_NUMBER" from TABLE1 TXT_2 inner join TABLE2 TXT_3 on TXT_2."ID_NUMBER" = TXT_3."ID_NUMBER" right join TABLE3 TXT_4 on TXT_4."PROSPECT_ID" = TXT_3."PROSPECT_ID" inner join TABLE4 TXT_5 on TXT_5."PROSPECT_ID" = TXT_4."PROSPECT_ID" , TABLE0 TXT_6 where TXT_6."ID_NUMBER" = TXT_5."ID_NUMBER" ) FOR READ ONLY

Workaround

The only workaround for this issue is to split the query so that the subquery is processed first. Then, in a second query, the table is subsetted based on the results of the first query.
create table temp as SELECT table0.ID_NUMBER FROM dblib.table1 INNER JOIN dblib.table2 ON (table1.ID_NUMBER = table2.ID_NUMBER) RIGHT OUTER JOIN dblib.table3 ON (table3.PROSPECT_ID = table2.PROSPECT_ID) INNER JOIN dblib.table4 ON (table4.PROSPECT_ID = table3.PROSPECT_ID) INNER JOIN dblib.table0 ON (table0.ID_NUMBER = table4.ID_NUMBER) WHERE table2.ACTIVE = 'Y' AND table2.TYPE IN ( 'PM', 'PT') ; create table results2 as select DISTINCT ID_NUMBER FROM dblib.table0 where id_number in (select * from temp);


Operating System and Release Information

Product FamilyProductSystemSAS Release
ReportedFixed*
SAS SystemSAS/ACCESS Interface to DB2z/OS9.2 TS1M09.4 TS1M0
Microsoft® Windows® for 64-Bit Itanium-based Systems9.2 TS1M0
Microsoft Windows Server 2003 Datacenter 64-bit Edition9.2 TS1M0
Microsoft Windows Server 2003 Enterprise 64-bit Edition9.2 TS1M0
Microsoft Windows XP 64-bit Edition9.2 TS1M0
Microsoft® Windows® for x649.2 TS1M09.4 TS1M0
Microsoft Windows Server 2003 Datacenter Edition9.2 TS1M0
Microsoft Windows Server 2003 Enterprise Edition9.2 TS1M0
Microsoft Windows Server 2003 Standard Edition9.2 TS1M0
Microsoft Windows XP Professional9.2 TS1M0
Windows Vista9.2 TS1M0
Windows Vista for x649.2 TS1M0
64-bit Enabled AIX9.2 TS1M09.4 TS1M0
64-bit Enabled HP-UX9.2 TS1M09.4 TS1M0
64-bit Enabled Solaris9.2 TS1M09.4 TS1M0
HP-UX IPF9.2 TS1M0
Linux9.2 TS1M0
Linux for x649.2 TS1M09.4 TS1M0
Solaris for x649.2 TS1M09.4 TS1M0
SAS SystemSAS/ACCESS Interface to GreenplumMicrosoft® Windows® for x649.2 TS2M09.4 TS1M0
Microsoft Windows Server 2003 Datacenter Edition9.2 TS2M0
Microsoft Windows Server 2003 Enterprise Edition9.2 TS2M0
Microsoft Windows Server 2003 Standard Edition9.2 TS2M0
Microsoft Windows Server 2003 for x649.2 TS2M0
Microsoft Windows Server 2008 for x649.2 TS2M09.4 TS1M0
Microsoft Windows XP Professional9.2 TS2M0
Windows Vista9.2 TS2M0
Windows Vista for x649.2 TS2M0
64-bit Enabled AIX9.2 TS2M09.4 TS1M0
64-bit Enabled Solaris9.2 TS2M09.4 TS1M0
HP-UX IPF9.2 TS2M0
Linux9.2 TS2M0
Linux for x649.2 TS2M09.4 TS1M0
Solaris for x649.2 TS2M09.4 TS1M0
SAS SystemSAS/ACCESS Interface to HP NeoviewMicrosoft Windows Server 2003 Datacenter Edition9.2 TS1M0
Microsoft Windows Server 2003 Enterprise Edition9.2 TS1M0
Microsoft Windows Server 2003 Standard Edition9.2 TS1M0
Microsoft Windows XP Professional9.2 TS1M0
Windows Vista9.2 TS1M0
Windows Vista for x649.2 TS1M0
64-bit Enabled Solaris9.2 TS1M0
HP-UX IPF9.2 TS1M0
Linux9.2 TS1M0
SAS SystemSAS/ACCESS Interface to Informix64-bit Enabled AIX9.2 TS1M09.4 TS1M0
64-bit Enabled HP-UX9.2 TS1M09.4 TS1M0
64-bit Enabled Solaris9.2 TS1M09.4 TS1M0
HP-UX IPF9.2 TS1M0
Linux for x649.2 TS1M09.4 TS1M0
SAS SystemSAS/ACCESS Interface to Microsoft SQL Server64-bit Enabled AIX9.2 TS1M09.4 TS1M0
64-bit Enabled HP-UX9.2 TS1M09.4 TS1M0
64-bit Enabled Solaris9.2 TS1M09.4 TS1M0
HP-UX IPF9.2 TS1M09.4 TS1M0
Linux for x649.2 TS1M09.4 TS1M0
SAS SystemSAS/ACCESS Interface to MySQLMicrosoft® Windows® for x649.2 TS1M09.4 TS1M0
Microsoft Windows Server 2003 Datacenter Edition9.2 TS1M0
Microsoft Windows Server 2003 Enterprise Edition9.2 TS1M0
Microsoft Windows Server 2003 Standard Edition9.2 TS1M0
Microsoft Windows XP Professional9.2 TS1M0
Windows Vista9.2 TS1M0
Windows Vista for x649.2 TS1M0
64-bit Enabled AIX9.2 TS1M09.4 TS1M0
64-bit Enabled HP-UX9.2 TS1M09.4 TS1M0
64-bit Enabled Solaris9.2 TS1M09.4 TS1M0
HP-UX IPF9.2 TS1M0
Linux9.2 TS1M0
Linux for x649.2 TS1M09.4 TS1M0
Solaris for x649.2 TS1M09.4 TS1M0
SAS SystemSAS/ACCESS Interface to NetezzaMicrosoft® Windows® for x649.2 TS1M09.4 TS1M0
Microsoft Windows Server 2003 Datacenter Edition9.2 TS1M0
Microsoft Windows Server 2003 Enterprise Edition9.2 TS1M0
Microsoft Windows Server 2003 Standard Edition9.2 TS1M0
Microsoft Windows XP Professional9.2 TS1M0
Windows Vista9.2 TS1M0
Windows Vista for x649.2 TS1M0
64-bit Enabled AIX9.2 TS1M09.4 TS1M0
64-bit Enabled HP-UX9.2 TS1M09.4 TS1M0
64-bit Enabled Solaris9.2 TS1M09.4 TS1M0
HP-UX IPF9.2 TS1M0
Linux9.2 TS1M0
Linux for x649.2 TS1M09.4 TS1M0
SAS SystemSAS/ACCESS Interface to ODBCMicrosoft® Windows® for 64-Bit Itanium-based Systems9.2 TS1M0
Microsoft Windows Server 2003 Datacenter 64-bit Edition9.2 TS1M0
Microsoft Windows Server 2003 Enterprise 64-bit Edition9.2 TS1M0
Microsoft Windows XP 64-bit Edition9.2 TS1M0
Microsoft® Windows® for x649.2 TS1M09.4 TS1M0
Microsoft Windows Server 2003 Datacenter Edition9.2 TS1M0
Microsoft Windows Server 2003 Enterprise Edition9.2 TS1M0
Microsoft Windows Server 2003 Standard Edition9.2 TS1M0
Microsoft Windows XP Professional9.2 TS1M0
Windows Vista9.2 TS1M0
Windows Vista for x649.2 TS1M0
64-bit Enabled AIX9.2 TS1M09.4 TS1M0
64-bit Enabled HP-UX9.2 TS1M09.4 TS1M0
64-bit Enabled Solaris9.2 TS1M09.4 TS1M0
HP-UX IPF9.2 TS1M0
Linux9.2 TS1M0
Linux for x649.2 TS1M09.4 TS1M0
Solaris for x649.2 TS1M09.4 TS1M0
SAS SystemSAS/ACCESS Interface to Aster nClusterMicrosoft® Windows® for x649.2 TS2M09.4 TS1M0
Microsoft Windows Server 2003 Datacenter Edition9.2 TS2M0
Microsoft Windows Server 2003 Enterprise Edition9.2 TS2M0
Microsoft Windows Server 2003 Standard Edition9.2 TS2M0
Microsoft Windows Server 2003 for x649.2 TS2M0
Microsoft Windows Server 2008 for x649.2 TS2M09.4 TS1M0
Microsoft Windows XP Professional9.2 TS2M0
Windows Vista9.2 TS2M0
Windows Vista for x649.2 TS2M0
Linux9.2 TS2M0
Linux for x649.2 TS2M09.4 TS1M0
SAS SystemSAS/ACCESS Interface to OLE DBMicrosoft® Windows® for 64-Bit Itanium-based Systems9.2 TS1M0
Microsoft Windows Server 2003 Datacenter 64-bit Edition9.2 TS1M0
Microsoft Windows Server 2003 Enterprise 64-bit Edition9.2 TS1M0
Microsoft Windows XP 64-bit Edition9.2 TS1M0
Microsoft® Windows® for x649.2 TS1M09.4 TS1M0
Microsoft Windows Server 2003 Datacenter Edition9.2 TS1M0
Microsoft Windows Server 2003 Enterprise Edition9.2 TS1M0
Microsoft Windows Server 2003 Standard Edition9.2 TS1M0
Microsoft Windows XP Professional9.2 TS1M0
Windows Vista9.2 TS1M0
Windows Vista for x649.2 TS1M0
SAS SystemSAS/ACCESS Interface to Oraclez/OS9.2 TS1M09.4 TS1M0
Microsoft® Windows® for 64-Bit Itanium-based Systems9.2 TS1M0
Microsoft Windows Server 2003 Datacenter 64-bit Edition9.2 TS1M0
Microsoft Windows Server 2003 Enterprise 64-bit Edition9.2 TS1M0
Microsoft Windows XP 64-bit Edition9.2 TS1M0
Microsoft® Windows® for x649.2 TS1M09.4 TS1M0
Microsoft Windows Server 2003 Datacenter Edition9.2 TS1M0
Microsoft Windows Server 2003 Enterprise Edition9.2 TS1M0
Microsoft Windows Server 2003 Standard Edition9.2 TS1M0
Microsoft Windows XP Professional9.2 TS1M0
Windows Vista9.2 TS1M0
Windows Vista for x649.2 TS1M0
64-bit Enabled AIX9.2 TS1M09.4 TS1M0
64-bit Enabled HP-UX9.2 TS1M09.4 TS1M0
64-bit Enabled Solaris9.2 TS1M09.4 TS1M0
HP-UX IPF9.2 TS1M0
Linux9.2 TS1M0
Linux for x649.2 TS1M09.4 TS1M0
OpenVMS on HP Integrity9.2 TS1M0
Solaris for x649.2 TS1M09.4 TS1M0
SAS SystemSAS/ACCESS Interface to SybaseMicrosoft Windows Server 2003 Datacenter Edition9.2 TS1M0
Microsoft Windows Server 2003 Enterprise Edition9.2 TS1M0
Microsoft Windows Server 2003 Standard Edition9.2 TS1M0
Microsoft Windows XP Professional9.2 TS1M0
Windows Vista9.2 TS1M0
Windows Vista for x649.2 TS1M0
64-bit Enabled AIX9.2 TS1M09.4 TS1M0
64-bit Enabled HP-UX9.2 TS1M09.4 TS1M0
64-bit Enabled Solaris9.2 TS1M09.4 TS1M0
HP-UX IPF9.2 TS1M0
Linux9.2 TS1M0
Linux for x649.2 TS1M09.4 TS1M0
Solaris for x649.2 TS1M09.4 TS1M0
SAS SystemSAS/ACCESS Interface to Sybase IQMicrosoft® Windows® for x649.2 TS2M09.4 TS1M0
Microsoft Windows Server 2003 Datacenter Edition9.2 TS2M0
Microsoft Windows Server 2003 Enterprise Edition9.2 TS2M0
Microsoft Windows Server 2003 Standard Edition9.2 TS2M0
Microsoft Windows Server 2003 for x649.2 TS2M0
Microsoft Windows Server 2008 for x649.2 TS2M09.4 TS1M0
Microsoft Windows XP Professional9.2 TS2M0
Windows Vista9.2 TS2M0
Windows Vista for x649.2 TS2M0
64-bit Enabled AIX9.2 TS2M09.4 TS1M0
64-bit Enabled HP-UX9.2 TS2M09.4 TS1M0
64-bit Enabled Solaris9.2 TS2M09.4 TS1M0
HP-UX IPF9.2 TS2M0
Linux9.2 TS2M0
Linux for x649.2 TS2M09.4 TS1M0
Solaris for x649.2 TS2M09.4 TS1M0
SAS SystemSAS/ACCESS Interface to Teradataz/OS9.2 TS1M09.4 TS1M0
Microsoft Windows Server 2003 Datacenter Edition9.2 TS1M0
Microsoft Windows Server 2003 Enterprise Edition9.2 TS1M0
Microsoft Windows Server 2003 Standard Edition9.2 TS1M0
Microsoft Windows XP Professional9.2 TS1M0
Windows Vista9.2 TS1M0
Windows Vista for x649.2 TS1M0
64-bit Enabled AIX9.2 TS1M09.4 TS1M0
64-bit Enabled HP-UX9.2 TS1M09.4 TS1M0
64-bit Enabled Solaris9.2 TS1M09.4 TS1M0
HP-UX IPF9.2 TS1M0
Linux9.2 TS1M0
Linux for x649.2 TS1M09.4 TS1M0
Solaris for x649.2 TS1M09.4 TS1M0
* For software releases that are not yet generally available, the Fixed Release is the software release in which the problem is planned to be fixed.