ref_countries::get_country_code (public)

 ref_countries::get_country_code -country country

Defined in packages/ref-countries/tcl/ref-countries-procs.tcl

Gets the country code for a country

Switches:
-country
(required)
Name of the country in English!

Partial Call Graph (max 5 caller/called nodes):
%3 test_get_country_code get_country_code (test ref-countries) ref_countries::get_country_code ref_countries::get_country_code test_get_country_code->ref_countries::get_country_code db_string db_string (public) ref_countries::get_country_code->db_string template::util::list_of_lists_to_array template::util::list_of_lists_to_array (public) ref_countries::get_country_code->template::util::list_of_lists_to_array

Testcases:
get_country_code
Source code:

    set country_code [db_string get_country_code "select iso from countries where default_name = upper(:country)" -default ""]

    if { $country_code eq "" } {

        # Lets try to be smart.
        set country_list [list  [list England GB]  [list "Great Britain" GB]  [list Korea KR]  [list Scotland GB]  [list "South Korea" SK]  [list "Taiwan, R.O.C." TW]  [list "The Netherlands" NL]  [list UK GB]  [list USA US]  [list "United States of America" US]]

        template::util::list_of_lists_to_array $country_list countries

        if {([info exists countries($country)] && $countries($country) ne "")} {
            set country_code $countries($country)
        }
    }

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