好的,这是在纯SQL中执行此操作的方法...
create table if not exists test1(id integer primary key, val integer); create trigger test1_ins_trigger after insert on test1 when new.val < 1000 begin insert into test1(val) values(new.val + 1); end; pragma recursive_triggers = 1; insert into test1(val) values(1);
CREATE TEMP TABLE Bits (Bit INTEGER PRIMARY KEY); INSERT INTO Bits VALUES (0); INSERT INTO Bits VALUES (1); CREATE TEMP TABLE Nums AS SELECT b9.Bit * 512 + b8.Bit * 256 + b7.Bit * 128 + b6.Bit * 64 + b5.Bit * 32 + b4.Bit * 16 + b3.Bit * 8 + b2.Bit * 4 + b1.Bit * 2 + b0.Bit AS Num FROM Bits b9, Bits b8, Bits b7, Bits b6, Bits b5, Bits b4, Bits b3, Bits b2, Bits b1, Bits b0; CREATE TABLE Test1 (ID INTEGER PRIMARY KEY, Val INTEGER); INSERT INTO Test1 SELECT Num, 3 FROM Nums WHERE Num BETWEEN 1 AND 1000;