firebird icon indicating copy to clipboard operation
firebird copied to clipboard

No error is given when using multiple WHEN MATCHED THEN UPDATE clause without the condition

Open berserk-cpp opened this issue 1 month ago • 0 comments

Firebird-6.0.0.1338

No error is given,

SQL> merge into test_1 t1 
CON>     using (select * from test_2) t2 on (t1.id = t2.id) 
CON>     WHEN MATCHED THEN 
CON>         update set js = t2.js 
CON>     WHEN MATCHED THEN
CON>         update set jst = t2.jst;
SQL> select * from test_1;

but the second update is not execute.

------------Original----------------------
ID                              1
JS                              {"A":11}
JST                             {"A":[1,1,1]}
JSB                             {"A":{"B":[1,1,1]}}
JSSM                            {"Small1":"data_json"}
------------After merge-------------------
ID                              1
JS                              {"A":22}
JST                             {"A":[1,1,1]}
JSB                             {"A":{"B":[1,1,1]}}
JSSM                            {"Small1":"data_json"}

MSSQL 2022 An action of type 'WHEN MATCHED' cannot appear more than once in a 'UPDATE' clause of a MERGE statement.

Oracle 21c ORA-00905: missing keyword

PostgreSQL 17 unreachable WHEN clause specified after unconditional WHEN clause

berserk-cpp avatar Nov 05 '25 08:11 berserk-cpp