创建函数时报错:Error Code: 1418. This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you might want to use the less safe log_bin_trust_function_creators variable)
则需执行如下代码:
set global log_bin_trust_function_creators = 1;
存储过程
无参数
delimiter //
drop procedure if exists hw;
create procedure hw()
begin
select "aaaa";
end
//
有参数
in输入参数:
多个参数用逗号分开,SQL语句最后需加分号
delimiter //
create procedure addteacher(in p_tname varchar(20),in p_tsex varchar(4))
begin
insert into teacher (tname,tsex) values(p_tname,p_tsex);
end;//
OUT输出参数:
delimiter //
drop procedure if exists selecttname;
create PROCEDURE selecttname(in p_sname varchar(20),out p_tname varchar(20))
begin
#将查询结果赋值给参数
select tname into p_tname from teacher where sname=p_sname;
end;
//
delimiter ;