I know SQLite have last_insert_rowid()
function. I'd like to create a similar function but I want to retrieve an array of indexes, each one coming from an insert or update into my db.
To be clearer, I have a populated table like this (name is UNIQUE):
rowid name age
1 'John' 18
2 'Anne' 25
3 'Jack' 32
Then I have to insert or update few lines:
('John',19), ('Michael',33), ('Jenny',12)
Result will be:
rowid name age
1 'John' 19
2 'Anne' 25
3 'Jack' 32
4 'Michael' 33
5 'Jenny' 12
And rowids inserted/updated are: 1,4,5
How may I retrieve those indexes? JS answer would be nice, anyway even in other languages I suppose I should understand.
I solved using two triggers. The logical flow is: