2014/7/24
初學存儲過程
DELIMITER // 定義寫存儲過程中的結束符為 //
創建存儲過程1:
create procedure proce_userinfo(in name varchar(10) ,int pwd varchar(10),out flag int)
begin
select power from user where Username=name and password=pwd into flag;
end //
創建存儲過程2:
create procedure proc_reg(in name varchar(10),in pwd varchar(10),out flag int)
begin
set @count=0;
select count(*) from users where username=name into @count;
if @count>0 then
set flag=0;
else
set flag=1;
insert into users(username,passwords)values (name,pwd);
end if;
end
declare 僅僅是聲明,set既聲明又賦值
2014/7/24