WITH 子句在 SQLite 的 TRIGGER 中不起作用?
WITH clause not working inside a TRIGGER in SQLite?
最小可重现示例:
create table t (f text);
create view v (f) as select f from t;
create trigger g instead of insert on v
begin
with w (f) as (select 'f')
insert into t select f from w;
end;
给出:
Error: near line 5: in prepare, near "insert": syntax error (1)
当这工作正常时:
create table t (f text);
with w (f) as (select 'f')
insert into t select f from w;
根据 documentation 支持触发器内的 with 子句。不知道出了什么问题。有什么想法吗?
根据您链接到的同一个 documentation,它在 2.1:
部分下明确说明
Common table expression are not supported for statements inside of triggers.
最小可重现示例:
create table t (f text);
create view v (f) as select f from t;
create trigger g instead of insert on v
begin
with w (f) as (select 'f')
insert into t select f from w;
end;
给出:
Error: near line 5: in prepare, near "insert": syntax error (1)
当这工作正常时:
create table t (f text);
with w (f) as (select 'f')
insert into t select f from w;
根据 documentation 支持触发器内的 with 子句。不知道出了什么问题。有什么想法吗?
根据您链接到的同一个 documentation,它在 2.1:
部分下明确说明Common table expression are not supported for statements inside of triggers.