存储过程中的begin end的作用
有如下的储存过程:
create proc proc_deluser
(@user_id varchar(20),
@user_name varchar(30),
@user_role char(1)
)
as
if(exists(select * from users where user_id=@user_id and user_name=@user_name and user_role=@user_role))
begin
delete from users
where user_id =@user_id
delete from edub where user_id=@user_id
delete from xzkh where user_id=@user_id
return 1
end
return -1
第一个begin--end是属于if语句块里的,相当于你编程里面的大括号,最后的return相当于else里面的。整个代码其实如果满足if()就返回1,否则返回-1