zoukankan      html  css  js  c++  java
  • 存储过程

    1.创建存储过程:

      create procedure show(in id int)

      begin

      select * from sc where  xuehao=id;

      end

    2.使用存储过程:

      call show(10)

    3.复杂操作:

      drop procedure show;    //删除存储过程;

      create procedure show(in id int)

      begin

      declare  couts int

      select count(*) into cous  from sc where  xuehao = id;

      if  couts=0 

      then  select "用户不存在"

      else  

        select * from sc where xuhao = id

      end if

      end

      call show(100)

    4.传入多个参数

      create procedure show(in id int,in name varchar(255))

      .......

    5.创建购物车的存储过程,传入商品id,用户id,购买数量

      create procedure shop(in goods varchar(255),in id int,in x int)

      begin

      declear user int

      declear qt int

      select count(*)into user,quanlity into qt form shopcar where id=id and goodsid=goodsid

      if coun = 0

      then
      insert into shopcar(goodsid,id) values(goodsid,id);
      else   
      update shopcar set quantity=qt+x

      endif

      end

      shop(10,001,1000);

      

        

  • 相关阅读:
    vagrant
    webapp开发
    UIViewAnimationOptions swift 2
    swift 2
    autolayout 总结
    apache 403错
    hadoop配置优化
    hadoop配置优化
    使用spark访问elasticsearch的数据
    使用spark访问elasticsearch的数据
  • 原文地址:https://www.cnblogs.com/docter/p/5651482.html
Copyright © 2011-2022 走看看