时间:2021-07-01 10:21:17 帮助过:24人阅读
## 存储过程 IF 语句 DROP PROCEDURE IF EXISTS proce_if; delimiter ;; CREATE PROCEDURE porce_if (IN type INT) BEGIN ## begin end; 是存储过程的块标示方法,类似PHP函数中的 { } declare c VARCHAR(100); ## 定义一个 变长字符串 c IF type = 0 THEN SET c = ‘param is 0‘; ELSEIF type = 1 THEN SET c = ‘param is 1‘; ELSE set c = ‘param is others, not 0 or 1‘; END IF; SELECT c ; END;; delimiter; CALL porce_if(1);
## 存储过程 case 语句 感觉有点像 PHP 中的 switch 语句 DROP PROCEDURE IF EXISTS proce_case; delimiter ;; CREATE PROCEDURE proce_case (IN type INT) BEGIN ## begin end; 是存储过程的块标示方法,类似PHP函数中的 { } declare c VARCHAR(100); ## 定义一个 变长字符串 c CASE type WHEN 0 THEN SET c = ‘param is 0‘; WHEN 1 THEN SET c = ‘param is 1‘; ELSE set c = ‘param is others, not 0 or 1‘; END CASE; SELECT c; END;; delimiter; CALL proce_case(1);
Mysql存储过程
标签:begin 存储 运行 ges 函数 默认 oca fine log