Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Store Procedure IF query

Status
Not open for further replies.

Shahare

Programmer
Jan 27, 2011
5
IL
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
 

post the error message

please

[dazed]

However, you seem to have one more right parenthesis than left parenthesis which is likely to cause problems in anybody's language.

Andrew
 
you have an unbalanced parenthesis

you have a malformed SELECT statement

you used END where you shoulda used END IF

r937.com | rudy.ca
Buy my new book Simply SQL from Amazon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top