db_list_of_lists (public)
db_list_of_lists [ -dbn dbn ] [ -cache_key cache_key ] \ [ -cache_pool cache_pool ] [ -with_headers ] [ -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.
- -cache_key (optional)
- Cache the result using given value as the key. Default is to not cache.
- -cache_pool (optional, defaults to
"db_cache_pool"
)- Override the default db_cache_pool
- -with_headers (optional, boolean)
- when specified, first line of returned list of lists will always be the list of column names as reported by the database. Useful when you want to dynamically assign variables to values returned in the list of lists.
- -subst (optional, defaults to
"all"
)- Perform Tcl substitution in xql-files. Possible values: all, none, vars, commands
- -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 Tcl list, each element of which is a list of all column values in a row of the result of the SQL querysql. If sql doesn't return any rows, returns an empty list, unless with_headers flag was specified and in this case the only element in the list will be the list of headers. It checks if the element is I18N and replaces it, thereby reducing the need to do this with every single package
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- auth_authority_api, parameter__check_procs, db__caching, db__list_variants
Source code: set full_statement_name [db_qd_get_fullname $statement_name] db_with_handle -dbn $dbn db { set code { set result {} set selection [db_exec -subst $subst select $db $full_statement_name $sql] #ns_log notice "ll2: $sql -> $selection" #ns_log notice "ll2: $sql -> [ns_set array $selection]" if {$with_headers_p || $columns_var ne ""} { if {$columns_var ne ""} { upvar 1 $columns_var headers } if {[acs::icanuse "ns_set keys"]} { set headers [ns_set keys $selection] } else { set headers [dict keys [ns_set array $selection]] } if {$with_headers_p} { set result [list $headers] } } if {[acs::icanuse "ns_set values"]} { while { [db_getrow $db $selection] } { lappend result [ns_set values $selection] } } else { while { [db_getrow $db $selection] } { lappend result [dict values [ns_set array $selection]] } } set result } if { [info exists cache_key] } { return [ns_cache eval $cache_pool $cache_key $code] } else { return [eval $code] } } return $resultXQL Not present: Generic, PostgreSQL, Oracle