我已经创建了工作正常但它永远不会进入 if 块的过程。在 if 中,我将 leave_Type 与“Cl”进行比较。
CREATE DEFINER=`satish`@`%` PROCEDURE `p_Leave_Approval`(
IN uname varchar(45),
IN coment varchar(200),
IN approval varchar(1)
)
BEGIN
-- declare str varchar(2);
-- set str = 'CL';
SELECT Emp_ID INTO @empid
FROM employee
WHERE Emp_F_Name=uname;
UPDATE staff_leave_detail
SET Leave_Comment=coment
,Leave_Status=approval
WHERE Emp_ID=@empid
AND Leave_Status='P';
SELECT Leave_Start_Date, Leave_End_Date INTO @sd, @ed
FROM staff_leave_detail
WHERE Emp_ID=@empid AND Leave_Status='P';
SELECT DATEDIFF(@sd,@ed) AS 'd2 - d1' INTO @s;
SELECT Leave_Type INTO @lt
FROM staff_leave_detail
WHERE Emp_ID=@empid
AND Leave_Status='P';
IF @lt = 'CL' THEN
UPDATE staff_leave
SET AP_CL = AP_CL - @s ,
AV_CL = AV_CL + @S
WHERE Emp_ID = @empid ;
END IF;
END