On duplicate key update feature in H2 On duplicate key update feature in H2 sql sql

On duplicate key update feature in H2


You need to use the MySQL mode. To do that, append ;mode=MySQL to the database URL. (This feature is not properly documented yet).

The table needs to have a primary key or at least a unique index. Complete example:

drop table MREPORT;set mode MySQL;create table MREPORT(PRODUCTID int primary key, DESCRIPTION varchar, QUANTITY int,  SUBTOTAL int, PROFIT int);INSERT INTO MREPORT (PRODUCTID ,DESCRIPTION ,QUANTITY ,SUBTOTAL ,PROFIT ) VALUES (22,'olper',5,100,260) ON DUPLICATE KEY UPDATE QUANTITY = QUANTITY+5;