標籤:log style ack word class RoCE The 地區 arp
-- Mysql 預存程序/*set @result = 0;create procedure login(-- 定義參數,有in、out、inout三種類型in user varchar(10),in pass varchar(10),out result int)begin declare passd varchar(10);-- declare 聲明臨時變數、類型,然後用set 進行賦值,declare 臨時變數只能放在begin end 地區中,而其範圍也只是在begin end 中, 而 set @ 定義的變數是全域變數select password into passd from login where username=user;if passd like pass then-- If 語句,後面要加上 End IF,就像是case 後也要加 End Case 一樣select ‘Login Success‘ as Massage;set result = 1;elseselect ‘Login Failed‘ as Message;set result =0;end if;end;*/ -- 調用預存程序 call login(‘root‘,‘root‘,@result);-- 刪除預存程序 drop procedure login create procedure translate(id int)begincase idwhen 1 then select ‘one‘ as trans;when 2 thenselect ‘two‘ as trans;when 3 then select ‘three‘ as trans;elseselect ‘no trans‘ as trans;end case;end; /*case 用法有兩種:1. 條件變數在when 中select name, casewhen age>10 then xxxxxelsexxxxxxend case2. 條件變數在case 中select name,case agewhen >10 then xxx else xxxxxsend case*/
mysql中的預存程序和遊標