代码如下 | 复制代码 |
DELIMITER $$ CREATE DEFINER=`root`@`localhost` FUNCTION `UF_Get_tMaxCode`( 输入参数: 调用示例: 创建日期: */ IF V_iType IN (1,3) |
THEN
#非订单类
IF EXISTS (SELECT dtLast FROM tMaxCode WHERE iType=V_iType LIMIT 0,1)
THEN
SELECT IFNULL(iMax,0)+1 INTO iCode FROM tMaxCode WHERE iType=V_iType;
ELSE
SET iCode=1;
END IF;
SELECT IFNULL(iMax,0)+1 INTO iCode FROM tMaxCode WHERE iType=V_iType;
ELSE
#订单类
IF EXISTS (SELECT iMax FROM tMaxCode WHERE iType=V_iType AND DATEDIFF(dtLast,CURRENT_DATE)=0 LIMIT 0,1)
THEN
#上次生成时间是当天
SELECT IFNULL(iMax,0)+1 INTO iCode FROM tMaxCode WHERE iType=V_iType;
ELSE
SET iCode=1;
END IF;
END IF;
代码如下 | 复制代码 |
IF EXISTS (SELECT iMax FROM tMaxCode WHERE iType=V_iType LIMIT 0,1) DELIMITER ; |
?>