Index: openacs-4/packages/acs-tcl/tcl/00-database-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/Attic/00-database-procs.tcl,v diff -u -r1.122 -r1.123 --- openacs-4/packages/acs-tcl/tcl/00-database-procs.tcl 7 Feb 2019 14:08:56 -0000 1.122 +++ openacs-4/packages/acs-tcl/tcl/00-database-procs.tcl 7 Feb 2019 16:03:57 -0000 1.123 @@ -1647,11 +1647,14 @@ set cmd [list ::db_list_of_lists -dbn $dbn -with_headers \ $statement_name $sql] - set rows [uplevel 1 $cmd] - set headers [lindex $rows 0] - set rows [lrange $rows 1 end] - foreach row $rows { - if { [info exists column_array] || [info exists column_set] } { + set counter 0 + foreach row [uplevel 1 $cmd] { + incr counter + if {$counter == 1} { + # headers are the first list in returned tuples + set headers $row + continue + } elseif { [info exists column_array] || [info exists column_set] } { # User wants query results to be put inside ns_set or # array data structure. foreach header $headers value $row { @@ -1699,7 +1702,7 @@ } } # If the if_no_rows_code is defined, go ahead and run it. - if { [llength $rows] == 0 && [info exists if_no_rows_code_block] } { + if { $counter > 1 && [info exists if_no_rows_code_block] } { uplevel 1 $if_no_rows_code_block } }