Could someone please help me understand what is wrong with this query?
------------------------------------------------------------------------------DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `spAddNewCountry`(IN countryTag TEXT, IN countryName TEXT, IN langTag TEXT)
BEGIN
DECLARE countryId INT;
SET countryId = -1;
SELECT Country_Id INTO countryId FROM tbl_country WHERE Country_Tag = countryTag;
IF (countryId = -1) THEN
INSERT INTO tbl_country (Country_Id, Country_Tag)
SELECT NULL, countryTag;
END IF;
SELECT Country_Id INTO countryId FROM tbl_country WHERE Country_Tag = countryTag;
DECLARE translationId INT;
SET translationId = -1;
SELECT Translation_Id INTO translationId FROM tbl_translation WHERE Translation_Identification_Tag = countryTag);
IF (translationId = -1) THEN
BEGIN
INSERT INTO tbl_translations (Translation_Id, Translation_Identification_Tag, Data_Language_Id, Translation_Value)
SELECT NULL, countryTag, (SELECT Language_Id FROM tbl_language WHERE Language_Tag = langTag), countryName;
END;
END $$
------------------------------------------------------------------------------
Thanks
Shahar
------------------------------------------------------------------------------DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `spAddNewCountry`(IN countryTag TEXT, IN countryName TEXT, IN langTag TEXT)
BEGIN
DECLARE countryId INT;
SET countryId = -1;
SELECT Country_Id INTO countryId FROM tbl_country WHERE Country_Tag = countryTag;
IF (countryId = -1) THEN
INSERT INTO tbl_country (Country_Id, Country_Tag)
SELECT NULL, countryTag;
END IF;
SELECT Country_Id INTO countryId FROM tbl_country WHERE Country_Tag = countryTag;
DECLARE translationId INT;
SET translationId = -1;
SELECT Translation_Id INTO translationId FROM tbl_translation WHERE Translation_Identification_Tag = countryTag);
IF (translationId = -1) THEN
BEGIN
INSERT INTO tbl_translations (Translation_Id, Translation_Identification_Tag, Data_Language_Id, Translation_Value)
SELECT NULL, countryTag, (SELECT Language_Id FROM tbl_language WHERE Language_Tag = langTag), countryName;
END;
END $$
------------------------------------------------------------------------------
Thanks
Shahar