Subject Re: [firebird-support] Order by error in FB 1.5
Author Arno Brinkman

> I have a database with a lot of stored procs. I have moved from firebird
> 1.0x to 1.5 and when i try to recompile some stored procs i get the error
> Invalid expression in the ORDER BY clause (not contained in either an
> aggregate function or the GROUP BY clause)

> The expression is

> select max(NFIELD)
> from Table_X
> where IDTABLEX = :IDTableX
> into :NField;

> in previous versions i used the order by clause to force index
> selection, but do i have now to change all the metadata to make it
> compatible with 1.5x.

The error is correct, because IDTABLEX isn't a valid field in your query.
The ORDER is done after the aggregate-calculation and at that point there can be more IDTABLEX values for NFIELD.
With other words such a query in FB1.0 could give you wrong results.

Arno Brinkman

General database developer support:

Firebird open source database (based on IB-OE) with many SQL-99 features:

Support list for Interbase and Firebird users:

Nederlandse firebird nieuwsgroep: