Вы можете использовать функцию last_insert_rowid()
без сценария var для этого случая:
insert into parent (id, name) values (NULL, 'some name!');
затем:
insert into child (id, parentId, name) values (NULL, last_insert_rowid(), 'child name!');
расшифровка:
SQLite version 3.7.6.3
sqlite> create table parent (id integer primary key, name);
sqlite> create table child (id integer primary key, parentId integer, name);
sqlite> insert into parent (id, name) values (NULL, 'some name!');
sqlite> insert into child (id, parentId, name) values (NULL, last_insert_rowid(), 'child name!');
sqlite> select * from parent;
1|some name!
sqlite> select * from child;
1|1|child name!
sqlite>
Если вам нужно некоторое время сохранить значение (например, с помощью нескольких вставок), используйте временную таблицу:
sqlite> create temp table stash (id integer primary key, parentId integer);
sqlite> insert into parent (id, name) values (NULL, 'another name!');
sqlite> replace into stash values (1, last_insert_rowid());
sqlite> insert into child (id, parentId, name) values (NULL, (select parentID from stash where id = 1), 'also a name!');
sqlite> select * from parent;
1|some name!
2|another name!
sqlite> select * from child;
1|1|child name!
2|2|also a name!
sqlite>