SQLite Forum

tcl / db eval error
Login

tcl / db eval error

(1) By anonymous on 2020-04-21 09:30:17 [link] [source]

Starting SQL with a commet fails. Would be create to have db eval -- $sql {..} "--" as end of options.

regards Tillmann

This code fails. package require sqlite3

file delete ./testdb sqlite3 db1 ./testdb db1 eval {CREATE TABLE t1(a int, b text)} db1 eval {INSERT INTO t1 VALUES(1,'hello')} db1 eval {INSERT INTO t1 VALUES(2,'goodbye')} db1 eval {INSERT INTO t1 VALUES(3,'howdy!')}

lappend sql "-- This is a comment" lappend sql "SELECT * FROM t1 ORDER BY a"

db1 eval [join $sql n] values { parray values puts ""
}

(2) By Gerry Snyder (GSnyder) on 2020-04-21 16:56:27 in reply to 1 [source]

The [join ...] command creates the following string:

-- This is a commentnSELECT * FROM t1 ORDER BY a

I don't think this is what you want.

(3) By Peter da Silva (resuna) on 2020-06-08 13:14:00 in reply to 2 [link] [source]

Since the forums collapse escape sequences, the code was perhaps [join $sql \n]?