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):
- 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 $resultXQL Not present: Generic, PostgreSQL, Oracle