delete order by

31 views
Skip to first unread message

Gabriel Zerbib

unread,
Dec 16, 2019, 9:28:15 AM12/16/19
to H2 Database
Hello,

MySQL supports ( since at leat >5.5) an ORDER BY clause with the DELETE statement.

this does not seem to be supported by H2 (tested version: 1.4.197), even with MODE=MYSQL in the datasource name.
Providing a query like :

DELETE FROM table1 ORDER BY field1 DESC LIMIT 100

leads to a Syntax Error (whereas this is a valid query with MySQL).

Syntax error in SQL statement "DELETE FROM table1 WHERE field1 < ? ORDER[*] BY TS DESC "; SQL statement:
[42000-197]
org.h2.jdbc.JdbcSQLException: 
at org.h2.message.DbException.getJdbcSQLException(DbException.java:357)
at org.h2.message.DbException.get(DbException.java:179)
at org.h2.message.DbException.get(DbException.java:155)
at org.h2.message.DbException.getSyntaxError(DbException.java:203)
at org.h2.command.Parser.getSyntaxError(Parser.java:548)
at org.h2.command.Parser.prepareCommand(Parser.java:281)
at org.h2.engine.Session.prepareLocal(Session.java:611)
at org.h2.engine.Session.prepareCommand(Session.java:549)
at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1247)
at org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:76)
at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:304)
        ...


Is it possible to implement it? at least, in a way that the parser  will accept it, even if not really performed on the data?

Thanks,
Gabriel

Reply all
Reply to author
Forward
0 new messages