USE test;

DROP PROCEDURE IF EXISTS pro_testincrement;
DELIMITER &&
CREATE PROCEDURE pro_testincrement(IN inr int)
BEGIN
DECLARE i INT DEFAULT 0;
select max(id) into i from test.testpro;
update test.testpro set id = id+inr where id = i;
select max(id) from test.testpro;
END && 
DELIMITER ;


mysql> call pro_testincrement (3);
+---------+
| max(id) |
+---------+
| 68 |
+---------+
1 row in set (0.01 sec)

Query OK, 0 rows affected (0.01 sec)

mysql> call pro_testincrement (3);
+---------+
| max(id) |
+---------+
| 71     |
+---------+
1 row in set (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

mysql> call pro_testincrement (1);
+---------+
| max(id) |
+---------+
| 72      |
+---------+
1 row in set (0.02 sec)

Query OK, 0 rows affected (0.02 sec)

  

相关文章:

  • 2022-12-23
  • 2021-12-25
  • 2021-07-26
  • 2021-05-16
  • 2021-08-21
  • 2022-12-23
  • 2022-12-23
  • 2021-05-17
猜你喜欢
  • 2022-03-10
  • 2022-02-26
  • 2021-08-18
  • 2021-12-23
  • 2021-09-18
  • 2022-12-23
相关资源
相似解决方案