MBG SQLite
Not logged in

Intarray SQLite3 extension for Tcl

Debian binary and src packages available by link sqlite3-intarray-tcl

Load this extension as

package require sqlite3-intarray

Simple example based on upstream Tcl test script:

#!/usr/bin/tclsh
package require sqlite3
package require sqlite3-intarray

  sqlite3 db :memory:

  db eval {
    CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
  }
  for {set i 1} {$i<=999} {incr i} {
    set b [format {x%03d} $i]
    db eval {INSERT INTO t1(a,b) VALUES($i,$b)}
  }
  puts [db eval {
    CREATE TABLE t2(x INTEGER PRIMARY KEY, y);
    INSERT INTO t2 SELECT * FROM t1;
    SELECT b FROM t1 WHERE a IN (12,34,56,78) ORDER BY a
  }]

  set ia3 [sqlite3_intarray_create db ia3]
  puts [db eval {
    SELECT type, name FROM sqlite_temp_master
     ORDER BY name
  }]

  puts [db eval {
    SELECT b FROM t1 WHERE a IN ia3 ORDER BY a
  }]

  sqlite3_intarray_bind $ia3 45 123 678
  puts [db eval {
    SELECT b FROM t1 WHERE a IN ia3 ORDER BY a
  }]

See upstream Tcl test script for examples test/intarray.test