My Oracle Support Banner

Wrong Results When Using Inlist And Comparing Char And Varchar2 (Doc ID 1566476.1)

Last updated on FEBRUARY 27, 2019

Applies to:

Oracle Database - Enterprise Edition - Version 11.2.0.3 and later
Oracle Database Cloud Schema Service - Version N/A and later
Oracle Database Exadata Cloud Machine - Version N/A and later
Oracle Cloud Infrastructure - Database Service - Version N/A and later
Oracle Database Exadata Express Cloud Service - Version N/A and later
Information in this document applies to any platform.

Symptoms

Combination of join predicate with CHAR and VARCHAR operands and inlist predicate with the same CHAR operand can cause wrong result

Example Scenario:

CREATE TABLE djw ( A char(4) , B date ) ;
create index djw_ind on djw(B,A) ;

INSERT INTO djw VALUES ('A' ,sysdate ) ;
INSERT INTO djw VALUES ('AA',SYSDATE ) ;
INSERT INTO djw VALUES ('AAA' ,SYSDATE) ;

CREATE TABLE djw2 ( A varchar2(4) ) ;

INSERT INTO djw2 VALUES ('A' ) ;
INSERT INTO djw2 VALUES ('AA' ) ;
INSERT INTO djw2 VALUES ('AAA' ) ;
INSERT INTO djw2 VALUES ('AAAA' ) ;

commit ;

When the following queries are executed:


SELECT count(*) FROM djw, djw2 WHERE djw.A = rpad(djw2.A,4) AND djw.A IN ('A','AAAA') AND djw.b > SYSDATE -1
returns 1 row
SELECT count(*) FROM djw, djw2 WHERE djw.A = rpad(djw2.A,4) AND djw.A IN ('AAAA','A') AND djw.b > SYSDATE -1
returns 0  row

Changes

 

Cause

To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!


In this Document
Symptoms
Changes
Cause
Solution
References


My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.