Excerpts from Daniel Polski's message of 2015-09-24 09:50:36 -0300: > > Hello again, > I think I can simplify the actual question: > > Can I use a SELECT returning multiple rows as input to some INSERT > logic, and in that logic INSERT into multiple tables?
That was exactly what I showed you using only one table. (INSERT always insert in one Table, only exception is for views (INSTEAD OF) triggers). > > Like if I have a table t1 containing id 1, 2, 3. > > For each id in t1, do > INSERT INTO t2 (...) > INSERT INTO t3 (...) --But this depends on the last_insert_rowid() from > the insert into t2 above > > The problem for me is that I don't know how to fetch the > last_insert_rowid() needed for the t3 table. (If I didn't have to split > up the insert I could simply run something like INSERT INTO t2 SELECT id > FROM t1; ) You can't use last_insert_rowid because it only stores a single value. In order to have the list of values you have somehow to create a variable for that. One way is to use temporary tables, but I think this is not possible in a trigger (to have a CREATE statement). The other way is what I suggested you: create a new trigger for t2 itself to check on the values inserted. > > Best Regards, > Daniel -- Marco Arthur @ (M)arco Creatives