我有以下语句,我想根据它的一些列条目更新表。我使用 Firebird 2.1,文档显示更新可以与 CTE 一起使用,但我的 Flamerobin 顽固地坚持认为更新语句无法识别。你能对此有所了解吗?
with cte as (select gen_id(gen_new,1) as num , N.elm_prof, N.elm_mat From
(select distinct elm_mat, elm_prof from elements ) N )
update elements E set E.PROP_TYPE = cte.num where cte.elm_prof = E.ELM_PROF and cte.elm_mat = E.ELM_MAT
Engine Message :
Dynamic SQL Error
SQL error code = -104
Token unknown - line 3, column 1
update
merge into elements E1
using (with CTE as (select distinct e2.ELM_MAT mat1, e2.ELM_PROF mat2 from elements e2)
select gen_id(gen_new,1) num, mat1, mat2 from cte)
on E1.elm_mat = mat1 and e1.elm_prof = mat2
when matched then update set e1.prop_type = num