db_get_database (public)

 db_get_database [ -dbn dbn ]

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

PostgreSQL and NSDB only. Return the database name from the first database pool. It assumes the datasource is properly formatted since we've already verified that we can connect to the pool. On the longer range, it might be better to use SQL queries, at least in cases, where database is already connected. PostgreSQL: SELECT current_database() Oracle: SELECT name from v$database; SELECT ora_database_name FROM dual

Switches:
-dbn
(optional)
The database name to use. If empty_string, uses the default database.
Returns:
database name

Partial Call Graph (max 5 caller/called nodes):
%3 db_load_sql_data db_load_sql_data (public) db_get_database db_get_database db_load_sql_data->db_get_database db_source_sql_file db_source_sql_file (public) db_source_sql_file->db_get_database packages/acs-subsite/www/admin/system/db-locks.tcl packages/acs-subsite/ www/admin/system/db-locks.tcl packages/acs-subsite/www/admin/system/db-locks.tcl->db_get_database db_available_pools db_available_pools (public) db_get_database->db_available_pools

Testcases:
No testcase defined.
Source code:
    set pool [lindex [db_available_pools $dbn] 0]
    set datasource [ns_config "ns/db/pool/$pool" DataSource]
    set last_colon_pos [string last ":" $datasource]
    if { $last_colon_pos == -1 } {
        ns_log Error "datasource contains no \":\"? datasource = $datasource"
        return ""
    }
    set dbname [string range $datasource $last_colon_pos+1 end]
    set equal_pos [string first "=" $dbname]
    if {$equal_pos > -1} {
        # The value after the last colon is a
        regexp {dbname=([^ ]+) ?} $dbname . dbname
    }
    return $dbname
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: