mysql存储过程书写

来源:互联网 发布:linux groupadd 编辑:程序博客网 时间:2024/06/10 05:20

1 存储过程if else

DROP PROCEDURE IF EXISTS insertOrganization;

CREATE PROCEDURE insertOrganization(IN o varchar(39),IN  sName VARCHAR(100))  
BEGIN  
    set @orgType=if((o in ('0000')),1,0);
    IF(@orgType = 1) THEN    /*属于组织*/
          select "1";
    END IF;  
    IF(@orgType = 0) THEN   /*属于部门*/
           select "0";
    END IF;  

END;


call insertOrganization('00000','');   //调用存储过程


2 select给存储过程赋值,用into方式

SET @one := 1;
select @one;

select A.id into @one from A where id=6;

原创粉丝点击