Mysql MySqlDump database backup code (1/2)

Source: Internet
Author: User
The code is as follows: Copy code

DELIMITER $

Create definer = 'root' @ 'localhost' FUNCTION 'uf _ get_tmaxcode '(
V_iType INT
) RETURNS varchar (10) CHARSET utf8
BEGIN
/*
Business Description: code is generated based on the encoding category.

Input parameters:
V_iType: specifies the encoding type and defines the iType field for tMaxCode creation.

Call example:
SELECT UF_Get_tMaxCode (1 );

Creation date:
Created:

*/
DECLARE iCode INT;

IF V_iType IN (1, 3)

THEN
# Non-order type
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
# Order type
If exists (SELECT iMax FROM tMaxCode WHERE iType = V_iType and datediff (dtLast, CURRENT_DATE) = 0 LIMIT 0, 1)
THEN
# The last generation time is the same day
Select ifnull (iMax, 0) + 1 INTO iCode FROM tMaxCode WHERE iType = V_iType;
ELSE
SET iCode = 1;
End if;
End if;

Homepage 1 2 Last page
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.