Carlos wrote:
SELECT * FROM SSIRRA where
(YEAR = 2004 and CUSTOMER = 0000000004 and CODE = 00 and PART >= 00) or
(YEAR = 2004 and CUSTOMER = 0000000004 and CODE > 00) or
(YEAR = 2004 and CUSTOMER > 0000000004) or
(YEAR > 2004)
[snip]
ah, the positional query. You can always rewrite this query in the
following form:
(YEAR >= 2004) and
(YEAR = 2004 or CUSTOMER >= 0000000004) and
(YEAR = 2004 or CUSTOMER = 0000000004 or CODE >= 00) and
(YEAR = 2004 or CUSTOMER = 0000000004 or CODE = 00 or PART > 00)
This is better because it will index scan using 'year' (not customer or
part though). The true answer is to lobby for/develop proper row
constructor support so you can just
SELECT * FROM SSIRRA where (YEAR, CUSTOMER, CODE, PART) > (2004,
0000000004, 00, 00)
this is designed to do what you are trying to do but currently doesn't
work quite right.
note: in all these queries, 'order by YEAR, CUSTOMER, CODE, PART' should
probably be on the query.
Other solution: use cursor/fetch or some type of materialized solution.
Merlin