db_list (public)

 db_list [ -dbn dbn ] [ -cache_key cache_key ] \
    [ -cache_pool cache_pool ] [ -subst subst ] 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
(defaults to "db_cache_pool") (optional)
Override the default db_cache_pool
-subst
(defaults to "all") (optional)
Perform Tcl substitution in xql-files. Possible values: all, none, vars, commands
-bind
(optional)
bind variables, passed either as an ns_set id, or via bind value list
Parameters:
statement_name
sql
Returns:
a Tcl list of the values in the first column of the result of SQL query sql. If sql doesn't return any rows, returns an empty list.

Partial Call Graph (max 5 caller/called nodes):
%3 test_db__caching db__caching (test acs-tcl) db_list db_list test_db__caching->db_list test_db__list_variants db__list_variants (test acs-tcl) test_db__list_variants->db_list db_exec db_exec (public) db_list->db_exec db_getrow db_getrow (private) db_list->db_getrow db_qd_get_fullname db_qd_get_fullname (public) db_list->db_qd_get_fullname db_with_handle db_with_handle (public) db_list->db_with_handle acs_mail_lite::inbound_queue_pull acs_mail_lite::inbound_queue_pull (private) acs_mail_lite::inbound_queue_pull->db_list acs_mail_lite::inbound_queue_release acs_mail_lite::inbound_queue_release (private) acs_mail_lite::inbound_queue_release->db_list acs_object_type::supertypes acs_object_type::supertypes (private) acs_object_type::supertypes->db_list acs_sc::contract::get_operations acs_sc::contract::get_operations (public) acs_sc::contract::get_operations->db_list acs_user_extension::list_extensions acs_user_extension::list_extensions (public) acs_user_extension::list_extensions->db_list

Testcases:
db__caching, db__list_variants
Source code:

    # Query Dispatcher (OpenACS - SDW)
    set full_statement_name [db_qd_get_fullname $statement_name]

    # Can't use db_foreach in this proc, since we need to use the ns_set directly.

    set code {
        db_with_handle -dbn $dbn db {
            set selection [db_exec -subst $subst select $db $full_statement_name $sql]
            set result [list]
            while { [db_getrow $db $selection] } {
                lappend result [ns_set value $selection 0]
            }
        }
        return $result
    }
    if { [info exists cache_key] } {
        return [ns_cache eval $cache_pool $cache_key $code]
    } else {
        return [eval $code]
    }
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: