db_foreach (public)

 db_foreach [ -dbn dbn ] [ -subst subst ] statement_name sql \
    [ args... ]

Defined in packages/acs-tcl/tcl/01-database-procs.tcl

Usage:

db_foreach statement-name sql [ -bind bind_set_id | -bind bind_value_list ] [ -column_array array_name | -column_set set_name ] code_block [ if_no_rows if_no_rows_block ]

Performs the SQL query sql, executing code_block once for each row with variables set to column values (or a set or array populated if -column_array or column_set is specified). If the query returns no rows, executes if_no_rows_block (if provided). In place of 'if_no_rows' also the 'else' keyword can be used.

Example:

db_foreach greeble_query "select foo, bar from greeble" {
        ns_write "<li>foo=$foo; bar=$bar\n"
    } if_no_rows {
        # This block is optional.
        ns_write "<li>No greebles!\n"
    }

Switches:
-dbn
(optional)
The database name to use. If empty_string, uses the default database.
-subst
(defaults to "all") (optional)
Parameters:
statement_name
sql

Partial Call Graph (max 5 caller/called nodes):
%3 test_db__db_foreach db__db_foreach (test acs-tcl) db_foreach db_foreach test_db__db_foreach->db_foreach test_db__transaction_bug_3440 db__transaction_bug_3440 (test acs-tcl) test_db__transaction_bug_3440->db_foreach ad_arg_parser ad_arg_parser (public) db_foreach->ad_arg_parser aa_test::get_test_doc aa_test::get_test_doc (private) aa_test::get_test_doc->db_foreach acs_mail_lite::send_immediately acs_mail_lite::send_immediately (private) acs_mail_lite::send_immediately->db_foreach acs_mail_lite::sweeper acs_mail_lite::sweeper (private) acs_mail_lite::sweeper->db_foreach acs_messaging_process_queue acs_messaging_process_queue (private) acs_messaging_process_queue->db_foreach acs_object_type_hierarchy acs_object_type_hierarchy (public) acs_object_type_hierarchy->db_foreach

Testcases:
db__db_foreach, db__transaction_bug_3440
[ show source ]
Show another procedure: