Posted to tcl by aspect at Sat Mar 05 01:05:54 GMT 2016view raw

  1. package require sqlite3
  2. sqlite3 db ""
  3.  
  4. set n 2
  5. set s 2
  6. expr {$n}
  7. string length $s
  8.  
  9. db eval {create table t (t, c text); insert into t values ('text','2'), ('numeric',2);}
  10. puts [db eval {select t from t where c=$s}] ;# text numeric
  11. puts [db eval {select t from t where c=$n}] ;# text numeric
  12.  
  13. puts [db eval {select t from t where c>$s}] ;#
  14. puts [db eval {select t from t where c>$n}] ;#
  15. db eval {drop table t}
  16.  
  17. db eval {create table t (t, c numeric); insert into t values ('text','2'), ('numeric',2);}
  18. puts [db eval {select t from t where c=$s}] ;# text numeric
  19. puts [db eval {select t from t where c=$n}] ;# text numeric
  20.  
  21. puts [db eval {select t from t where c>$s}] ;#
  22. puts [db eval {select t from t where c>$n}] ;#
  23. db eval {drop table t}
  24.  
  25. db eval {create table t (t, c); insert into t values ('text','2'), ('numeric',2);}
  26. puts [db eval {select t from t where c=$s}] ;# text
  27. puts [db eval {select t from t where c=$n}] ;# numeric
  28.  
  29. # '2' > 2
  30. puts [db eval {select t from t where c>$s}] ;#
  31. puts [db eval {select t from t where c>$n}] ;# text
  32. db eval {drop table t}
  33.  
  34.