Icon View Incident Report

Serious Serious
Reported By: Richard Harding
Reported On: 12/3/2009
For: Version 2.03 Build 6
# 3111 Aggregate Queries with HAVING Clause Used as Sub-Select with IN Clause Can Return Incorrect Results

The following query is returning incorrect results, unless the DISTINCT keyword is added to the outer query.

Wrong:

SELECT ID, FName, MName, LName FROM Contacts C1
  WHERE  C1.FName ||C1.MName || C1.LName IN
     (SELECT C2.FName ||C2.MName || C2.LName
      FROM Contacts C2
      GROUP BY  FName, MName, LName
      HAVING COUNT(*) > 1)

ID, FName, MName, LName
2 | Mary | A | Doe |     
4 | Mary | A | Doe |   

Correct:

SELECT DISTINCT ID, FName, MName, LName FROM Contacts C1
  WHERE  C1.FName ||C1.MName || C1.LName IN
     (SELECT C2.FName ||C2.MName || C2.LName
      FROM Contacts C2
      GROUP BY  FName, MName, LName
      HAVING COUNT(*) > 1)

ID, FName, MName, LName
1 | John | W | Doe | JR 
6 | John | W | Doe | JR
2 | Mary | A | Doe |     
4 | Mary | A | Doe |     



Comments Comments and Workarounds
The problem had to do with the way that the outer IN query was returning a sensitive result set. The workaround was to request an insensitive result set, which was essentially what the DISTINCT clause caused to happen.

The problem was caused by internal parse tokens not being updated properly during a copy of the tokens made for the sensitive result set.


Resolution Resolution
Fixed Problem on 12/6/2009 in version 2.03 build 7


Products Affected Products Affected
ElevateDB Additional Software and Utilities
ElevateDB DAC Client-Server
ElevateDB DAC Client-Server with Source
ElevateDB DAC Standard
ElevateDB DAC Standard with Source
ElevateDB DAC Trial
ElevateDB LCL Standard with Source
ElevateDB VCL Client-Server
ElevateDB VCL Client-Server with Source
ElevateDB VCL Standard
ElevateDB VCL Standard with Source
ElevateDB VCL Trial

Image