mysql/core_cities_merge.sql
authorEdward <edward@roojs.com>
Thu, 26 Jun 2014 10:23:52 +0000 (18:23 +0800)
committerEdward <edward@roojs.com>
Thu, 26 Jun 2014 10:23:52 +0000 (18:23 +0800)
mysql/core_cities_merge.sql

index 9075099..d0596c8 100644 (file)
@@ -271,6 +271,16 @@ CREATE FUNCTION core_country_locations()  RETURNS INT DETERMINISTIC
             IF (v_continent_code != '') THEN
                 SELECT id INTO v_continent_id FROM core_geoip_continent WHERE code = v_continent_code;
 
+                IF v_continent_id = 0 THEN
+                    INSERT INTO core_geoip_continent (code, name) VALUES (v_continent_code, v_continent_name);
+                    SET v_continent_id = LAST_INSERT_ID();
+                END IF;
+                
+            END IF;
+
+            IF (v_country_iso_code != '') THEN
+                SELECT id INTO v_country_id FROM core_geoip_continent WHERE code = v_continent_code;
+
                 IF v_continent_id = 0 THEN
                     INSERT INTO core_geoip_continent (code, name) VALUES (v_continent_code, v_continent_name);
                 END IF;