On 4/19/16, Nikos Tsikoudis <tsikudis at brandeis.edu> wrote: > On 4/19/2016 8:25 PM, Richard Hipp wrote: >> https://www.sqlite.org/c3ref/interrupt.html >> >> Or have your function throw an error using sqlite3_result_error() - >> https://www.sqlite.org/c3ref/result_blob.html >> > That works but in the function I update another table in the same > database and after the interrupt or the error throw the updates have not > taken place....
Works when I try it. The TCL script I used to test is as follows: sqlite3 db :memory: db eval { CREATE TABLE t1(x); INSERT INTO t1(x) VALUES(1),(2),(3),(4); CREATE TABLE t2(y); } proc user_func {x} { db eval {INSERT INTO t2(y) VALUES($x)} if {$x==3} { sqlite3_interrupt db # Comment out the previous and replace with # error "all done here" # to terminate using an error rather than an interrupt } else { return $x } } db function user_func user_func catch { db eval { SELECT user_func(x) FROM t1; } } res puts res=$res puts [db eval {SELECT * FROM t2}] This prints the values "1 2 3" on the last line in both cases - when the loop is terminated using sqlite3_interrupt or when the loop is terminated by throwing an error. -- D. Richard Hipp drh at sqlite.org