create PROCEDURE v4(in c_year int)
BEGIN
declare num int(10) default 0;
declare num1 int(10);
select code into num from class where class=c_year order by code desc limit 1; IF exists(select * from class where class=c_year) THEN insert into class(class,code)values(c_year,num+1);
else
insert into class(class,code)values(c_year,1);
end if; end;

  

BEGIN
DECLARE a_class VARCHAR (10);
DECLARE a_code int (10);
DECLARE a_int INT (10);
SELECT IFNULL(class, class) INTO a_class;
select SUBSTR('0000',4,4)+'0' into a_code;
select a_int=a_code+1;
IF class = a_class THEN
IF a_int<10 THEN
insert into class(class,code)VALUES(a_class,CONCAT(a_class,'000',a_int));
elseIF a_int <100 THEN
insert into class(class,code)VALUES(a_class,CONCAT(a_class,'00',a_int));
elseIF a_int <1000 THEN
insert into class(class,code)VALUES(a_class,CONCAT(a_class,'0',a_int));
elseif a_int<10000 THEN
insert into class(class,code)VALUE(a_class,concat(a_class,a_int));
end if;
end if;
set a_int=a_code+1;
end

  

create PROCEDURE class_a(in c_year int)
begin
declare num int;
if exists(select * from class where class=c_year) then
update class set code=code+1 where class=c_year;
else
insert into class(class,code)values(c_year,1);
end if;
select code into num from class where class=c_year;
select CONCAT(c_year, lpad(num,4,0)) as code_a; end;

  

最新文章

  1. cacti监控windows服务器
  2. Unity官网教程之Tips
  3. Django 源码小剖: Django ORM 查询管理器
  4. json数据获取
  5. [FML]学习笔记三 Rademacher Complexity
  6. python第三方模块
  7. windows live writer插件说明文档(附录网盘地址)
  8. JQuery+CSS3实现封装弹出登录框效果
  9. CSS中的浮动清除
  10. 从零开始学JavaWeb
  11. 【转】 Python调用(运行)外部程序
  12. 痞子衡嵌入式:开启NXP-MCUBootUtility工具的HAB签名功能 - CST(中英双语)
  13. [Linux] Linux的环境变量
  14. Python学习之旅(二十五)
  15. Linux系列教程(四)——Linux常用命令之文件和目录处理命令
  16. 根据ip地址获取用户所在地
  17. libvlc_new 调用产生段错误
  18. CSS style 属性
  19. node.js入门基础
  20. 微信JS-SDK实现上传图片功能

热门文章

  1. VS中OpenCV用imread读取不到图片
  2. 收集的照片信息都是Excel超链接?批量命名很困难?来试试这个自制的下载器吧!
  3. shell-的特殊变量-难点理论
  4. Python+Appium自动化测试(4)-使用weditor进行元素定位
  5. DM9000时序设置
  6. Java 移位运算、符号位扩展
  7. ip地址和网络端口总结
  8. main函数标准写法
  9. 【UER #1】DZY Loves Graph
  10. linux(centos8):安装jmeter5.3