Posted to tcl by stu at Wed Feb 21 19:17:16 GMT 2018view pretty
proc giantSquid {q} { foreach v [lsearch -all -inline [tdbc::tokenize $q] :*] { set k [string range $v 1 end] uplevel 1 [subst -nocommands {if {![info exists $k]} { error {Billy sez: "My dog's name is: '$k'!"}}}] } return $q } # Usage: # set query "SELECT COUNT(*) FROM `$table(data)` WHERE `this`=:that AND `command`=:command AND `data`=:insert" # if {![$tdbc(1) allrows -as lists [giantSquid $query]]} { ... } # Test: package require tdbc proc z {} { set table(data) cow set that that set command command set insert insert set q "SELECT COUNT(*) FROM `$table(data)` WHERE `this`=:that AND `command`=:command AND `data`=:insert" puts [giantSquid $q] };z