Skip to Main Content

Database Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Allow all comparisons for row values

Thorsten KettnerAug 19 2021 — edited Aug 23 2021

This is allowed:

SELECT * FROM emp WHERE (dept, sal) = ((1, 100));

And in another idea I am proposing to allow row values on the right-hand side instead of a data set:

SELECT * FROM emp WHERE (dept, sal) = (1, 100);

What is not supported is this:

SELECT * FROM emp WHERE (dept, sal) < ((1, 100));

resp.

SELECT * FROM emp WHERE (dept, sal) < (1, 100);

The same applies to <= , >, and >= of course.
The SQL standard allows this and it is very useful when using pagination. So far we must use this to get the next 50 rows:

SELECT * 
FROM programs
WHERE version > :version
  OR (version = :version AND subversion > :subversion)
  OR (version = :version AND subversion = :subversion AND subsubversion > :subsubversion)
ORDER BY version, subversion, subsubversion
FETCH NEXT 50 ROWS ONLY; 

While in standard SQL we would just use:

SELECT * 
FROM programs
WHERE (version, subversion, subsubversion) > (:version, :subversion, :subsubversion)
ORDER BY version, subversion, subsubversion
FETCH NEXT 50 ROWS ONLY;

(And in conclusion it should be possible then to use the comparision operators on data sets, too: WHERE (version, subversion) >= all (select version, subversion from ...).)

Comments
Post Details
Added on Aug 19 2021
10 comments
218 views