MySQL Forums
Forum List  »  Stored Procedures

Nested If problem
Posted by: Russel James
Date: April 26, 2016 02:10PM

Im having a problem trying to a nested if statement inside a srpoc.

Here is code that works fine.

CREATE DEFINER=`root`@`localhost` PROCEDURE `usp_StatementsForCountry`(
IN p_countryID varchar(7),
IN p_overdueOnly boolean
)
BEGIN


if p_overdueOnly = false THEN
SELECT 1;
elseif p_overdueOnly = true THEN
SELECT 2;
END if;
END


But this is what I am trying to do..

CREATE DEFINER=`root`@`localhost` PROCEDURE `usp_StatementsForCountry`(
IN p_countryID varchar(7),
IN p_overdueOnly boolean
)
BEGIN


if p_overdueOnly = false THEN
if p_countryID = "DE" THEN
SELECT 1;
elseif p_countryID = "BE" THEN
SELECT 3;
end if
elseif p_overdueOnly = true THEN
SELECT 2;
END if;
END

Options: ReplyQuote


Subject
Views
Written By
Posted
Nested If problem
3047
April 26, 2016 02:10PM
728
April 26, 2016 05:49PM
692
April 26, 2016 11:20PM
1083
April 27, 2016 05:29AM
767
April 27, 2016 08:14AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.