#!/bin/sh # FILE: "/mnt/light_huge_archive/home/evmik/src/my_src/GradeBook/db_procs.tcl" # LAST MODIFICATION: "Sun, 12 Dec 2010 23:50:57 -0500 (evmik)" # (C) 2010 by Eugeniy Mikhailov, # $Id:$ # vim:set ft=tcl: \ exec tclsh "$0" "$@" #load libtclsqlite3.so.0 Sqlite3 package require sqlite3 set dbfile "./testdb" sqlite3 db $dbfile proc createDB {db} { db eval {CREATE TABLE t1(FirstName text, LastName text)} db eval {INSERT INTO t1 VALUES('John','Lname1')} db eval {INSERT INTO t1 VALUES('Ale','Lname2')} db eval {INSERT INTO t1 VALUES('Dan','Lname3')} #db1 eval {ALTER TABLE t1 ADD c int } } proc htmlDBout {db} { #set x [db eval {SELECT * FROM t1 ORDER BY a}] #puts $x set show_header 1 puts "" db eval {SELECT * FROM t1 ORDER BY LastName} v { puts "" foreach index $v(*) { if { $show_header } { set show_header 0 foreach col $v(*) { puts -nonewline "" } puts "" puts "" } if { $index != "*" } { puts -nonewline "" } } puts "" } puts "
$col
$v($index)
" } #createDB db htmlDBout db