While going over the language reference to do some manual fixes, I came across the following caution (see https://firebirdsql.org/file/documentation/reference_manuals/fblangref25-en/html/fblangref25-dml-select.html#fblangref25-dml-select-orderby-unions

"""
Expressions whose calculation results are non-negative integers will be interpreted as column position numbers and will cause an exception if they fall outside the range from 1 to the number of columns.

Example:

    SELECT
      X, Y, NOTE
    FROM PAIRS
    ORDER BY X+Y DESC


* The number returned by a function or a procedure is unpredictable, regardless of whether the sort order is defined by the expression itself or by the column number
* Only non-negative integers are interpreted as column numbers
* An integer obtained by one-time evaluation of an expression or by parameter substitution is saved as a constant, because this value applies to all rows.
"""

I just tested this in Firebird 2.5 and 1.5, and this is not actually the case (and I would be surprised if it ever has been the case). The value of an expression itself is used to sort. As far as I'm aware only literal or parenthesized literal values can be used to identify column positions.

Any objections if I just remove this caution in the new version?

Mark
--
Mark Rotteveel


_______________________________________________
Firebird-docs mailing list
Firebird-docs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/firebird-docs

Reply via email to