调用存储过程和函数

        1.调用存储过程。        

        存储过程通过call语句来调用,其语法格式为:

        call 存储过程名称 参数。

# 首先定义个存储过程,并给参数
create procedure Count (in s int,out n int)
begin
select count(*) into n from books where id=s;
end

# 调用存储过程
call Count(1002,@n);

        2.调用存储函数。

# 定义存储函数
create function Count (s int)
returns int
begin
return(select count(*) from books where id=s);
end

# 调用存储函数
select Count(1002);


版权声明:本文为mx13156原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。