1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
| create definer = user1@`%` procedure procedure_name( IN parameter1 varchar(50), IN parameter2 decimal(15, 2), IN parameter3 decimal(10, 4), IN parameter4 tinyint(3), IN parameter5 varchar(32)) begin declare s_parameter1 varchar(32); declare s_parameter2 datetime; declare s_parameter3 datetime; declare s_parameter4 decimal(15,2); declare s_parameter5 bigint; declare s_parameter6 bigint;
select param1, param2, date_add((date_format(param3,'%Y-%m-%d %H:%i:%s')),interval 10 MINUTE ), # 时间+10分钟 date_add((date_format(param4,'%Y-%m-%d %H:%i:%s')),interval 10 MINUTE ) # 时间+10分钟 into s_parameter1, s_parameter2, s_parameter3, s_parameter4 from table1 where param1 = parameter1;
UPDATE table2 SET `param1` = 'test', `param2` = s_parameter1, `param3` = s_parameter2, `param4` = s_parameter3, `param5` = date_format(now(), '%Y-%m-%d %H:%i:%s'), # 设置时间为当前时间 `param6` = s_parameter4, `param7` = s_parameter5, `param8` = s_parameter6, `param9` = s_parameter6, `param10`= date_format(now(), '%Y-%m-%d %H:%i:%s') # 设置时间为当前时间 WHERE param1 = parameter1; if parameter2 * 0.015 < 500 then set s_parameter3 = 500; else set s_parameter3 = parameter2 * 0.015; end if; select max(id)+1 into s_parameter5 from table3; select max(id)+1 into s_parameter6 from table4; insert into table5(p1, p2, p3, p4) values (s_parameter1, s_parameter2, s_parameter3, s_parameter4);
end;
|