Home  >  Article  >  php教程  >  mysql MySqlDump数据库备份代码(1/2)

mysql MySqlDump数据库备份代码(1/2)

WBOY
WBOYOriginal
2016-06-13 10:07:271168browse

mysql教程 MySqlDump数据库教程备份代码

DELIMITER $$

CREATE DEFINER=`root`@`localhost` FUNCTION `UF_Get_tMaxCode`(
  V_iType INT
) RETURNS varchar(10) CHARSET utf8
BEGIN
/*
业务描述:根据编码类别产生编码

输入参数:
V_iType:编码类别,定义建tMaxCode的iType字段的定义

调用示例:
SELECT UF_Get_tMaxCode(1);

创建日期:
创建人:

*/
DECLARE iCode INT;

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; 1 2

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn