diff options
author | Eugeniy Mikhailov <evgmik@gmail.com> | 2011-01-19 22:43:20 -0500 |
---|---|---|
committer | Eugeniy Mikhailov <evgmik@gmail.com> | 2011-01-19 22:43:20 -0500 |
commit | 2dcd502529c7e58c2df11df9cf87b9797671484f (patch) | |
tree | 8ad6f1b85f15a62ca61b73581fe638d7c133670f | |
parent | 05a169883b2e38d922e23d9e864278dd6adf8811 (diff) | |
download | GradeBook-2dcd502529c7e58c2df11df9cf87b9797671484f.tar.gz GradeBook-2dcd502529c7e58c2df11df9cf87b9797671484f.zip |
added column names helper functions
Ignore-this: 95dabe680321b971f3cca054398b274f
darcs-hash:20110120034320-067c0-0a483d27537351a5dad2829bf7a151234c0ba41a.gz
-rwxr-xr-x | GradeBook.tcl | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/GradeBook.tcl b/GradeBook.tcl index f75d910..24aa194 100755 --- a/GradeBook.tcl +++ b/GradeBook.tcl @@ -506,18 +506,30 @@ proc ChangeGrades { permission_list user } { } } -proc DeleteColumnNonWeb { columnname } { - if { $columnname != "" } { - set eval_str [concat SELECT * FROM GradesTable ] +proc getColListFromTable { table } { + set eval_str [concat SELECT * FROM \'$table\' ] set err [catch {db eval $eval_str v {} } errStat] set old_column_list $v(*) - # removing the column name to be deleted from total list - set new_column_list {} - foreach cname $old_column_list { - if { $cname ne $columnname } { - lappend new_column_list \"$cname\" - } + return $old_column_list +} + +proc removeElementFromList { element2remove old_list } { + set new_list {} + foreach element $old_list { + if { $element2remove ne $element } { + lappend new_list \"$element\" } + } + return $new_list +} + +proc DeleteColumnNonWeb { columnname } { + if { $columnname != "" } { + + # removing the column name to be deleted from total list + + set old_column_list [getColListFromTable GradesTable] + set new_column_list [removeElementFromList $columnname $old_column_list] set sql_new_column_list [join $new_column_list ","] set eval_str "BEGIN TRANSACTION; CREATE TEMPORARY TABLE GradesTable_backup($sql_new_column_list); |