Question

I am using an embedded Apache Derby database and execute the following query:

SELECT 
    someUniqueValue, 
    row_number() over(ORDER BY someUniqueValue) as ROWID 
FROM 
    myTable;

someUniqueValue is a varchar.

I am getting the Exception:

java.sql.SQLFeatureNotSupportedException: Feature not implemented: WINDOW/ORDER BY

If i change the row_number() line in my query to:

row_number() over() as ROWID 

The query runs fine (although the result is useless for me).

The Derby documentation states this is supported. What am I doing wrong?

Was it helpful?

Solution

The link you posted is just a draft to specify how the feature should be implemented.

If you scroll down a bit you find:

An implementation of the ROW_NUMBER() window function is included in Derby starting with the 10.4.1.3 release. Limitations and usage description may be found in the Derby Reference Manual

When you then look at Derby manual (your link is not the manual) http://db.apache.org/derby/docs/10.10/ref/rreffuncrownumber.html you'll find a list of limitations:

  • Derby does not currently allow the named or unnamed window specification to be specified in the OVER() clause, but requires an empty parenthesis. This means the function is evaluated over the entire result set.
  • The ROW_NUMBER function cannot currently be used in a WHERE clause.
  • Derby does not currently support ORDER BY in subqueries, so there is currently no way to guarantee the order of rows in the SELECT subquery. An optimizer override can be used to force the optimizer to use an index ordered on the desired column(s) if ordering is a firm requirement.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top