I perform two queries and get strange result. I'd like to know why is this happening.
Now queries:
SELECT * FROM TABLE_A a, TABLE_B b, TABLE_C c
WHERE a.a = b.a (+)
AND b.c = c.c
AND a.a = 123;
Result is empty.
SELECT COUNT(*) FROM TABLE_A a, TABLE_B b, TABLE_C c
WHERE a.a = b.a (+)
AND b.c = c.c
AND a.a = 123;
Result is 1.
It is really the same query with different returned value.
Table A contains row with 'a' field = 123.
Table B does not contain rows as a.a = b.a.
How can nothing or 1 be returned for the same query?
Update:
When I make it this way
SELECT COUNT(*) FROM TABLE_A a, TABLE_B b, TABLE_C c
WHERE a.a = b.a (+)
AND b.c = c.c (+)
AND a.a = 123;
It works OK.
To process the LIKE conditions, Oracle divides the pattern into subpatterns consisting of one or two characters each. The two-character subpatterns begin with the escape character and the other character is %, or _, or the escape character.
The ESCAPE clause identifies the backslash (\) as the escape character. In the pattern, the escape character precedes the underscore (_). This causes Oracle to interpret the underscore literally, rather than as a special pattern matching character.
The LIKE operator returns true if the expression matches the pattern . Otherwise, it returns false. The NOT operator, if specified, negates the result of the LIKE operator.
Possibly you have indices or foreign key constraints that are not consistent with the table data. Since these two queries most likely use different indices, they return inconsistent data.
Have you temporarily disabled the constrataints, or set them up without validating that they have initially been valid (ENABLE NOVALIDATE
)?
Try to rebuild the indices and drop and recreate the foreign key constraints to see whether that fixes your problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With