我有以下表格:
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
)
然后我有以下合并声明:
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
http://hsqldb.org/doc/guide/dataaccess-chapt.html#dac_merge_statement上的文档声明“WHEN MATCHED”语句可以有一个额外的“AND”子句,如上所述,但是失败的是:
unexpected token: AND required: THEN : line: 4 [SQL State=42581, DB Errorcode=-5581]
这个功能有用还是我错过了什么? 使用HSQLDB 2.3.1。
谢谢!
该文档适用于2.3.3版和即将发布的2.3.4版。这些最新版本支持AND子句。