Diferència entre revisions de la pàgina «ASIX/M10/UF1/A05/E1»
Salta a la navegació
Salta a la cerca
| Línia 22: | Línia 22: | ||
<source> | <source> | ||
| − | Name | + | MariaDB [world]> call paisos_llengua("English"); |
| − | Anguilla | + | +--------------------------------------+ |
| − | American Samoa | + | | Name | |
| − | Antigua and Barbuda | + | +--------------------------------------+ |
| − | Australia | + | | Anguilla | |
| − | Belize | + | | American Samoa | |
| − | Bermuda | + | | Antigua and Barbuda | |
| − | Barbados | + | | Australia | |
| − | Canada | + | | Belize | |
| − | Cocos (Keeling) Islands | + | | Bermuda | |
| − | Christmas Island | + | | Barbados | |
| − | Cayman Islands | + | | Canada | |
| − | Falkland Islands | + | | Cocos (Keeling) Islands | |
| − | United Kingdom | + | | Christmas Island | |
| − | Gibraltar | + | | Cayman Islands | |
| − | Guam | + | | Falkland Islands | |
| − | Hong Kong | + | | United Kingdom | |
| − | Ireland | + | | Gibraltar | |
| − | Saint Kitts and Nevis | + | | Guam | |
| − | Saint Lucia | + | | Hong Kong | |
| − | Lesotho | + | | Ireland | |
| − | Marshall Islands | + | | Saint Kitts and Nevis | |
| − | Malta | + | | Saint Lucia | |
| − | Northern Mariana Islands | + | | Lesotho | |
| − | Montserrat | + | | Marshall Islands | |
| − | Norfolk Island | + | | Malta | |
| − | Niue | + | | Northern Mariana Islands | |
| − | Nauru | + | | Montserrat | |
| − | New Zealand | + | | Norfolk Island | |
| − | Palau | + | | Niue | |
| − | Saint Helena | + | | Nauru | |
| − | Seychelles | + | | New Zealand | |
| − | Turks and Caicos Islands | + | | Palau | |
| − | Tokelau | + | | Saint Helena | |
| − | Tonga | + | | Seychelles | |
| − | Tuvalu | + | | Turks and Caicos Islands | |
| − | United States Minor Outlying Islands | + | | Tokelau | |
| − | United States | + | | Tonga | |
| − | Saint Vincent and the Grenadines | + | | Tuvalu | |
| − | Virgin Islands, British | + | | United States Minor Outlying Islands | |
| − | Virgin Islands, U.S. | + | | United States | |
| − | Vanuatu | + | | Saint Vincent and the Grenadines | |
| − | Samoa | + | | Virgin Islands, British | |
| − | South Africa | + | | Virgin Islands, U.S. | |
| − | Zimbabwe | + | | Vanuatu | |
| + | | Samoa | | ||
| + | | South Africa | | ||
| + | | Zimbabwe | | ||
| + | +--------------------------------------+ | ||
| + | 44 rows in set (0.01 sec) | ||
| + | |||
| + | Query OK, 0 rows affected (0.01 sec) | ||
</source> | </source> | ||
Revisió del 15:40, 8 feb 2018
ASIX M10 UF1
Pt5. Codificació de funcions
Guillem Solà i Boeck (host: PC05)
Enunciat
Crear un procediment/funció, de tal forma que si li passem el nom d'un llenguatge, ens mostri els paisos que el tenen com a oficial.
Solució
CREATE DEFINER=`root`@`localhost` PROCEDURE `paisos_llengua`(in llenguatge varchar(30)) BEGIN DECLARE pais varchar(30); SELECT Country.Name FROM CountryLanguage JOIN Country ON Country.Code = CountryLanguage.CountryCode WHERE CountryLanguage.Language=llenguatge AND CountryLanguage.IsOfficial="T"; END
Execució
call paisos_llengua("English")
MariaDB [world]> call paisos_llengua("English");
+--------------------------------------+
| Name |
+--------------------------------------+
| Anguilla |
| American Samoa |
| Antigua and Barbuda |
| Australia |
| Belize |
| Bermuda |
| Barbados |
| Canada |
| Cocos (Keeling) Islands |
| Christmas Island |
| Cayman Islands |
| Falkland Islands |
| United Kingdom |
| Gibraltar |
| Guam |
| Hong Kong |
| Ireland |
| Saint Kitts and Nevis |
| Saint Lucia |
| Lesotho |
| Marshall Islands |
| Malta |
| Northern Mariana Islands |
| Montserrat |
| Norfolk Island |
| Niue |
| Nauru |
| New Zealand |
| Palau |
| Saint Helena |
| Seychelles |
| Turks and Caicos Islands |
| Tokelau |
| Tonga |
| Tuvalu |
| United States Minor Outlying Islands |
| United States |
| Saint Vincent and the Grenadines |
| Virgin Islands, British |
| Virgin Islands, U.S. |
| Vanuatu |
| Samoa |
| South Africa |
| Zimbabwe |
+--------------------------------------+
44 rows in set (0.01 sec)
Query OK, 0 rows affected (0.01 sec)