MySQL存储过程问题,错误1414

时间:2016-01-14 20:54:19

标签: mysql stored-procedures

我尝试运行此存储过程时遇到问题。它返回SQL Error 1414.我可以使用一些帮助。

CREATE DEFINER=`root`@`localhost` PROCEDURE `date_code.GetDateCode`(IN `CalenderYear` INT, IN `DayOfYear` INT, OUT `DateCode` CHAR(2))
LANGUAGE SQL
NOT DETERMINISTIC
CONTAINS SQL
SQL SECURITY DEFINER
COMMENT ""

BEGIN
DECLARE charFirst TINYINT;
DECLARE DateCode CHAR(2);
SET DateCode = "XX";

CASE
    WHEN CalendarYear >= 2000 AND CalendarYear <= 2009 THEN
        SET charFirst = 1;
    WHEN CalendarYear >= 2010 AND CalendarYear <= 2019 THEN
        SET charFirst = 0;
    WHEN CalendarYear >= 2020 AND CalendarYear <= 2029 THEN
        SET charFirst = 1;
    WHEN CalendarYear >= 2030 AND CalendarYear <= 2039 THEN
        SET charFirst = 0;
    WHEN CalendarYear >= 2040 AND CalendarYear <= 2049 THEN
        SET charFirst = 1;
 END CASE;

 IF charFirst = 1 THEN
    SELECT CONCAT(code, fiscal_code) INTO DateCode FROM months 
    WHERE CalendarYear = calendar_year 
    AND DayOfYear >= months.fiscal_month_day_of_year_begin 
    AND DayOfYear <= months.fiscal_month_day_of_year_end;
 ELSE
   SELECT CONCAT(fiscal_code, code) INTO DateCode FROM months 
    WHERE CalendarYear = calendar_year 
    AND DayOfYear >= months.fiscal_month_day_of_year_begin 
    AND DayOfYear <= months.fiscal_month_day_of_year_end;
 END IF;
END

这是我的表的副本......

Database Table 我需要知道如何从mysql命令提示符调用此存储过程。我试过......

SET @dc = "XX";
CALL `date_code.GetDateCode`(2016, 14, @dc);

这将返回SQL错误1414.感谢您的帮助

0 个答案:

没有答案