Atomic INSERT/SELECT in HSQLDB

Posted by PartlyCloudy on Stack Overflow See other posts from Stack Overflow or by PartlyCloudy
Published on 2010-04-09T18:45:04Z Indexed on 2010/04/11 21:53 UTC
Read the original article Hit count: 536

Filed under:
|
|

Hello,

I have the following hsqldb table, in which I map UUIDs to auto incremented IDs:

SHORT_ID (BIG INT, PK, auto incremented) | UUID (VARCHAR, unique)

Create command:

CREATE TABLE table (SHORT_ID BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, UUID VARCHAR(36) UNIQUE)

In order to add new pairs concurrently, I want to use the atomic MERGE INTO statement. So my (prepared) statement looks like this:

MERGE INTO table USING (VALUES(CAST(? AS VARCHAR(36)))) AS v(x) ON ID_MAP.UUID = v.x WHEN NOT MATCHED THEN INSERT VALUES v.x

When I execute the statement (setting the placeholder correctly), I always get a

Caused by: org.hsqldb.HsqlException: row column count mismatch

Could you please give me a hint, what is going wrong here?

Thanks in advance.

© Stack Overflow or respective owner

Related posts about sql

Related posts about hsqldb