1 set db [pg_connect -conninfo [list host = 192.168.1.33 user = dpsearch dbname = test password = nummer]] 2 package require pgtcl 3 package require pgintcl 4 set db [pg_connect -conninfo [list host = 192.168.1.33 user = dpsearch dbname = test password = nummer]] 5 proc dosql { {s} } { global db if {[catch {pg_exec $db $s} reply]} { puts "sql error : $reply,[pg_result $reply -error]" return "Error" } if {[pg_result $reply -status] == "PGRES_COMMAND_OK"} { catch {pg_exec $db "insert into history values (DEFAULT, [pg_quote $s] , 'now' , NULL)"} return {} } if {[pg_result $reply -status] != "PGRES_TUPLES_OK"} { puts "sql error: [pg_result $reply -error]" return "Error" } set res [pg_result $reply -llist] catch {pg_exec $db "insert into history values (DEFAULT, [pg_quote $s] , 'now' , NULL)"} return $res # we only put non-errors in the history # pg_result $reply -clear return } 6 dosql "select distinct band as t from songs where lower(substring(band,1,1)) = [pg_quote a] order by t asc" 7 foreach i {1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v w x y z} { set fz [open //192.168.0.1/Doc_root/Tmp/band/[tourl $i].html w] puts -nonewline $fz "
First Letter | Album | Artist | Song |
[tohtml $i] | " ; set j [lindex [dosql "select distinct lower(substring(album,1,1)) as t from songs where lower(substring(album,1,1)) = [pg_quote $i] order by t asc"] 0] ; if {$j != {}} { puts -nonewline $fz " * " } ; puts -nonewline $fz " | "; set j [lindex [dosql "select distinct lower(substring(band,1,1)) as t from songs where lower(substring(band,1,1)) = [pg_quote $i] order by t asc"] 0] ; if {$j != {}} { puts -nonewline $fz " * " } ; puts -nonewline $fz " | " ; set j [lindex [dosql "select distinct lower(substring(title,1,1)) as t from songs where lower(substring(title,1,1)) = [pg_quote $i] order by t asc"] 0] ; if {$j != {}} { puts -nonewline $fz " * " } ; puts $fz " |