db_list_of_ns_sets (public)

 db_list_of_ns_sets [ -dbn dbn ] [ -subst subst ] \
    [ -columns_var columns_var ] statement_name sql [ -bind bind ]

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

Switches:
-dbn (optional)
The database name to use. If empty_string, uses the default database.
-subst (optional, defaults to "all")
-columns_var (optional)
-bind (optional)
bind variables, passed either as an ns_set id, or via bind value list
Parameters:
statement_name (required)
name of the SQL query.
sql (required)
SQL query to be executed.
Returns:
a list of ns_sets with the values of each column of each row returned by the SQL query specified.
list of ns_sets, one per each row return by the SQL query

Partial Call Graph (max 5 caller/called nodes):
%3 test_db__caching db__caching (test acs-tcl) db_list_of_ns_sets db_list_of_ns_sets test_db__caching->db_list_of_ns_sets test_db__db_foreach db__db_foreach (test acs-tcl) test_db__db_foreach->db_list_of_ns_sets test_db__list_variants db__list_variants (test acs-tcl) test_db__list_variants->db_list_of_ns_sets test_db__transaction_bug_3440 db__transaction_bug_3440 (test acs-tcl) test_db__transaction_bug_3440->db_list_of_ns_sets acs::icanuse acs::icanuse (public) db_list_of_ns_sets->acs::icanuse db_exec db_exec (public) db_list_of_ns_sets->db_exec db_getrow db_getrow (private) db_list_of_ns_sets->db_getrow db_qd_get_fullname db_qd_get_fullname (public) db_list_of_ns_sets->db_qd_get_fullname db_with_handle db_with_handle (public) db_list_of_ns_sets->db_with_handle acs_mail_lite::check_bounces acs_mail_lite::check_bounces (private) acs_mail_lite::check_bounces->db_list_of_ns_sets forum::list_forums forum::list_forums (public) forum::list_forums->db_list_of_ns_sets fs::get_folder_contents fs::get_folder_contents (public, deprecated) fs::get_folder_contents->db_list_of_ns_sets notification::sweep::sweep_notifications notification::sweep::sweep_notifications (private) notification::sweep::sweep_notifications->db_list_of_ns_sets

Testcases:
db__db_foreach, db__caching, db__transaction_bug_3440, db__list_variants
Source code:
    set full_statement_name [db_qd_get_fullname $statement_name]

    #
    # For large queries, "db_list_of_ns_sets" might be suboptimal,
    # since it requires to held the results twice, needing more memory
    # compared to other variants. Often, this can be replaced easily,
    # sometimes replacing it might require some refactoring.
    #
    # This is e.g. the case for "select_notifications"; don't
    # complain about it for now.
    #
    if {$statement_name ne "select_notifications"} {
        ns_log notice "consider replacing: db_list_of_ns_sets $full_statement_name $sql"
    }

    db_with_handle -dbn $dbn db {
        set result [list]
        set selection [db_exec -subst $subst select $db $full_statement_name $sql]

        while { [db_getrow $db $selection] } {
            lappend result [ns_set copy $selection]
        }
        if {$columns_var ne ""} {
            upvar 1 $columns_var __columns
            if {[acs::icanuse "ns_set keys"]} {
                set __columns [ns_set keys $selection]
            } else {
                set __columns [dict keys [ns_set array $selection]]
            }
        }
    }

    return $result
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: