Posted to tcl by evilotto at Wed Apr 22 13:10:32 GMT 2015view pretty

package require sqlite3

sqlite db f.db
sqlite db2 f.db

db eval {create table if not exists foo (a,b)}

db eval {
 insert into foo values (1,2);
 insert into foo values (3,4);
}

db2 eval {begin}

db transaction {
 db eval {select a from foo} row {
   lappend todel $row(a)
 }

 db2 eval {insert into foo values (5,6) }

 foreach a $todel {
   db eval {delete from foo where a = $a}
 }
}