create procedure agex(in addage1 int,in addage2 int)
begin
declare curl_stu_id int;
declare curl_stu_sex varchar(5);
declare done int default 0;
declare curl_student cursor for select stu_id,stu_sex from t_student;
declare continue handler for not found set done=1; //若没有数据返回则将变量done设置为1
open curl_student;
repeat
fetch curl_student into curl_stu_id,curl_stu_sex;
if not done then
if curl_stu_Sex='男' then
update t_student set age=age+addage1 where stu_id=curl_stu_id;
else
update t_student set age=age+addage2 where stu_id=curl_stu_id;
end if;
end if;
until done end repeat;
close curl_student;
end

mysql触发的更多相关文章

  1. MySQL触发器之审计功能(转)

    [导读] 最近ITPUB技术论坛特意组织网络性讨论活动,关于数据库审计的话题,分享各自公司如何实现数据库审计.个人经验和构想,以及数据库审计的技巧,刚好有网友发了一个典型的审计需求,要帮他分析,以及教 ...

  2. mysql触发器之姓名转姓名拼音

    人员表people 字段:id,peopleNumber,name,namePinyin,sex,birthday,nation. namePinyin不用填写,根据name自动生成. wordlib ...

  3. MySQL5.7 GTID学习笔记,[MySQL 5.6] GTID实现、运维变化及存在的bug

      GTID(global transaction identifier)是对于一个已提交事务的全局唯一编号,前一部分是server_uuid,后面一部分是执行事务的唯一标志,通常是自增的. 下表整理 ...

  4. Mysql信息数据库:Information_schema

    1. Information_schema information_schema是mysql的信息数据库. 通过该库能够查看mysql以下的数据库,表.权限等信息. 在数据库中会默认生成这个库.inf ...

  5. mysql innodb事务的ACID及其实现的保证机制

    MySQL事务的ACID,一致性是最终目的.保证一致性的措施有:A原子性:靠undo log来保证(异常或执行失败后进行回滚).D持久性:靠redo log来保证(保证当MySQL宕机或停电后,可以通 ...

  6. MySQL5.7 GTID学习笔记

    GTID(global transaction identifier)是对于一个已提交事务的全局唯一编号,前一部分是server_uuid,后面一部分是执行事务的唯一标志,通常是自增的. 下表整理了G ...

  7. SQL注入之重新认识

    i春秋作家:anyedt 原文来自:https://bbs.ichunqiu.com/thread-41701-1-1.html 引言 作为长期占据 OWASP Top 10 首位的注入,认识它掌握它 ...

  8. 包、mode模式、if-else语句、switch语句

    目录 包 mode模式 if-else语句 循环 switch语句 包 //1 在同一个包下(文件夹下),包名必须一致 //2 以后,包名就是文件夹的名字 //3 同一个包下,同名函数只能有一个(in ...

  9. MySQL-12-innodb引擎补充

    innodb引擎保证事务的ACID 概念 redo log ---> 重做日志 ib_logfile0~1 50M 轮询使用 redo log buffer ---> redo内存区域 i ...

随机推荐

  1. matlab中sum

    来源:https://ww2.mathworks.cn/help/matlab/ref/sum.html?searchHighlight=sum&s_tid=doc_srchtitle#btv ...

  2. idea 2020.1 Mybatis log plugin破解插件

    下载 链接: https://pan.baidu.com/s/1FTgtJiyzxxaNxWLyX4OgZw 密码: w7w8 idea安装本地插件

  3. 在Linux下如何根据域名自签发OpenSSL证书与常用证书转换

    在Linux下如何根据域名自签发各种SSL证书,这里我们以Apache.Tomcat.Nginx为例. openssl自签发泛域名(通配符)证书 首先要有openssl工具,如果没有那么使用如下命令安 ...

  4. ORM查询相关的操作

    必知必会13条 import os os.environ.setdefault("DJANGO_SETTINGS_MODULE", "orm_practice.setti ...

  5. charles详解

    Charles抓包https:https://www.jianshu.com/p/ec0a38d9a8cf 浅谈charles抓取https原理:https://www.jianshu.com/p/4 ...

  6. 理解Go协程与并发(转)

    理解Go协程与并发   协程 Go语言里创建一个协程很简单,使用go关键字就可以让一个普通方法协程化: Copy package main import ( "fmt" " ...

  7. centos8安装fastdfs6.06集群方式一之:软件下载与安装

    一,查看本地centos的版本 [root@localhost lib]# cat /etc/redhat-release CentOS Linux release 8.1.1911 (Core) 说 ...

  8. laravel job 队列

    1.数据库建表 php artisan queue:table<span> </span>//队列任务表 php artisan queue:failed-table<s ...

  9. requirements基本使用

    requirements作用描述:很多 Python 项目中经常会包含一个 requirements.txt 文件,里面内容是项目的依赖包及其对应版本号的信息列表,即项目依赖关系清单,其作用是用来重新 ...

  10. mybatis逆向工程配置

    1.准备配置文件 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE generatorConf ...