Search code examples
mergehsqldb

HSQLDB merge WHEN MATCHED AND fails


I have the following tables:

create table WorkPendingSummary
(
    WorkPendingID int not null,
    WorkPendingDate date not null,
    Status varchar(20) not null,
    EndDate date null
)

create table WorkPendingSummaryStage
(
    WorkPendingID int not null,
    WorkPendingDate date not null,
    Status varchar(20) not null
)

I then have the following merge statement:

MERGE INTO WorkPendingSummary w USING  WorkPendingSummaryStage
     AS vals(WorkPendingID, WorkPendingDate, Status) 
     ON w.WorkPendingID = vals.WorkPendingID
   WHEN MATCHED AND vals.status = 'CLOSED'  
         THEN UPDATE SET w.workpendingdate = vals.workpendingdate, w.status = vals.status, w.enddate = current_time

The documentation at: http://hsqldb.org/doc/guide/dataaccess-chapt.html#dac_merge_statement states that the "WHEN MATCHED" statement can have an additional "AND" clause as I have above, however that fails with:

unexpected token: AND required: THEN : line: 4 [SQL State=42581, DB Errorcode=-5581]

Does this feature work or am I just missing something?
Using HSQLDB 2.3.1.

Thanks!


Solution

  • The documentation is for version 2.3.3 and forthcoming 2.3.4. The AND clause is supported in these latest versions.