From 0ffbae198ea0757e7037c7690fb65bc14e487315 Mon Sep 17 00:00:00 2001 From: Eugeniy Mikhailov Date: Fri, 15 Apr 2011 18:18:20 -0400 Subject: added general procedure to select a given value from a table Ignore-this: 40c7e8c8a7048184620c01918ed31ed5 darcs-hash:20110415221820-067c0-11a111938eb4b5085d32ff36c4766fb23a939408.gz --- GradeBook_lib.tcl | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'GradeBook_lib.tcl') diff --git a/GradeBook_lib.tcl b/GradeBook_lib.tcl index ddc3476..f534c84 100755 --- a/GradeBook_lib.tcl +++ b/GradeBook_lib.tcl @@ -795,23 +795,28 @@ proc htmlFooter {permission_list} { puts "" } - -proc SelectColValue4User { colname user } { +proc SelectColvalueFromTable { table column_of_interest col row_value } { + # select value of 'column_of_interest' from 'table' where 'col'='row_value' set value {} - set eval_str "SELECT \"$colname\" FROM GradesTable where UserName=\"$user\"" + set eval_str "SELECT \"$column_of_interest\" FROM \'$table\' WHERE \"$col\"=\"$row_value\"" set err [catch { db eval $eval_str v { - set value $v($colname) + set value $v($column_of_interest) } } errStat ] if { $err } { - htmlErrorMsg $errStat - dbg "the following error happen: $errStat" 3 + set msg_text "the following error happen in proc SelectColvalueFromTable while selecting from table $table $errStat" + htmlErrorMsg $msg_text + dbg $msg_text 3 set $value {} } return $value } +proc SelectColValue4User { colname user } { + return [SelectColvalueFromTable GradesTable $colname UserName $user] +} + proc ClassInfoHtml {} { set CourseTitle [SelectItemFromCourseInfoTable course_title] set CourseYear [SelectItemFromCourseInfoTable course_year] -- cgit v1.2.3