Den 2015-09-24 kl. 13:03, skrev Simon Slavin:
> On 24 Sep 2015, at 11:38am, Daniel Polski <daniel at agelektronik.se> wrote:
>
>> -- Here is where my real question starts. Can I fetch a list of rows in a 
>> trigger
>> -- and update different tables from that data?
> Create a VIEW which does this
>
> SELECT ... FROM t1 JOIN t2 ON t2.t1_id = t1.id
>
> Then set the triggers for the VIEW rather than either of the tables.
>

Hmmm.. I don't understand how I can split up the INSERT in the trigger 
to insert the rows in the view into t3, t4?

...
--Should make the trigger run:
INSERT INTO t3 VALUES(1, 'dummy');
INSERT INTO t4 VALUES(1, last_insert_rowid());

INSERT INTO t3 VALUES(2, 'dummy');
INSERT INTO t4 VALUES(2, last_insert_rowid());

(The insert into t4 need the last_insert_rowid() from the insert into t3)

/Daniel

Reply via email to