wkim / h2database

Automatically exported from code.google.com/p/h2database
0 stars 0 forks source link

Mode MySQL and LAST_INSERT_ID with argument #444

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hello,

I'm using H2 with mode Mysql.

My problem is with the function LAST_INSERT_ID which can accept one argument 
when we want have to the next value (like sequence). For example, Spring uses 
this syntax in this class:
https://src.springframework.org/svn/spring-maintenance/tags/initial/src/org/spri
ngframework/jdbc/core/support/MySQLMaxValueIncrementer.java

Syntax: update <TABLE> set ID = last_insert_id(ID +1);

Stacktrace:
Caused by: org.h2.jdbc.JdbcSQLException: Invalid parameter count for 
"LAST_INSERT_ID", expected count: "0"; SQL statement:
update BATCH_JOB_SEQ set ID = last_insert_id(ID + 1) [7001-170]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
    at org.h2.message.DbException.get(DbException.java:169)
    at org.h2.expression.Function.setParameter(Function.java:438)
    at org.h2.command.Parser.readFunction(Parser.java:2298)
    at org.h2.command.Parser.readTerm(Parser.java:2475)
    at org.h2.command.Parser.readFactor(Parser.java:2045)
    at org.h2.command.Parser.readSum(Parser.java:2032)
    at org.h2.command.Parser.readConcat(Parser.java:2005)
    at org.h2.command.Parser.readCondition(Parser.java:1870)
    at org.h2.command.Parser.readAnd(Parser.java:1851)
    at org.h2.command.Parser.readExpression(Parser.java:1843)
    at org.h2.command.Parser.parseUpdate(Parser.java:694)
    at org.h2.command.Parser.parsePrepared(Parser.java:426)

Can you add this function to h2 to be compatible with MySQL?

Thanks

Original issue reported on code.google.com by guer...@fullsix.com on 27 Feb 2013 at 4:08

GoogleCodeExporter commented 8 years ago

Original comment by thomas.t...@gmail.com on 7 Mar 2013 at 6:03