Forum OpenACS Q&A: Re: Problem with TCL

Collapse
3: Re: Problem with TCL (response to 1)
Posted by Kabowei Oki on
if {"$type" == "xxx"} {
set temp "select * from TABLE A"

if [catch {set selection [ns_db select $db $t_select] } errMsg ] {
ns_log Notice "Error Occured reading Table A $errMsg"
ns_db flush $db
ns_db releasehandle $db
ns_returnredirect "$redirectPage"
set t_abort "1"
ns_adp_abort
}
while { [ns_db getrow $db $selection ] } {
set someVariable [ns_set get $selection "date"]
set anotherVariable [ns_set get $selection "someValue"]
set t_var [concat $someVariable*$anotherVariable]
lappend record $t_var
}
}

if {"$type" == "yyy"} {
set temp "select * from TABLE B"


if [catch {set selection [ns_db select $db $t_select] } errMsg ] {
ns_log Notice "Error with select Table B $errMsg"
ns_db flush $db
ns_db releasehandle $db
ns_returnredirect "$redirectPage"
set t_abort "1"
ns_adp_abort
}
while { [ns_db getrow $db $selection ] } {
set someVariable [ns_set get $selection "date"]
set anotherVariable [ns_set get $selection "some_id"
set t_var [concat $someVariable*$anotherVariable]
lappend record $t_var

}
}

set result [join $record ","]

ns_db releasehandle $db

ns_puts "var output = \"$result;\""