Index: openacs-4/packages/acs-tcl/tcl/00-database-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/00-database-procs.tcl,v diff -u -N -r1.9 -r1.10 --- openacs-4/packages/acs-tcl/tcl/00-database-procs.tcl 17 Jan 2002 23:00:06 -0000 1.9 +++ openacs-4/packages/acs-tcl/tcl/00-database-procs.tcl 22 Feb 2002 19:00:58 -0000 1.10 @@ -284,6 +284,36 @@ return $result } +ad_proc -public db_list_of_ns_sets { + statement_name + sql + {args ""} +} { + Returns a list of ns_sets with the values of each column of each row + returned byt he sql query specified. + + @param statement_name The name of the query. + @param sql The SQL to be executed. + @param args Any additional arguments, such as a 'if_no_rows' + + @return list of ns_sets, one per each row return by the SQL query +} { + ad_arg_parser { bind } $args + + set full_statement_name [db_qd_get_fullname $statement_name] + + db_with_handle db { + set result [list] + set selection [db_exec select $db $full_statement_name $sql] + + while {[db_getrow $db $selection]} { + lappend result [ns_set copy $selection] + } + } + + return $result +} + proc_doc db_foreach { statement_name sql args } { Usage: db_foreach statement_name sql [-bind ns_set | list of bind variables] code_block [if_no_rows if_no_rows_code_block]