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

    创建过程

    create procedure demo(in par int)//in out inout   参数名字 参数类型 
    begin
    set @a = 123;//会话变量 对当前会话有效,全局的变量
    declare a int;//用普通变量要声明类型,只对一个作用域有用
    declare a int default 5;//直接声明并赋值
    set a = 123;//普通变量
    if a = 123 then
    end if;
    if a = 12345 then
    ……
    else
    ……
    end if;
    case a
    when 1 then  select xx;
    when 2 then select bb;
    end case;
    while a < 3000 do 
    insert into demo(a);
    set v = v+1;//条件一定要有自增运算,不然会一直while
    end whild;
    end;
    

    Loop

    loop没有条件, 所以需要用If判断 然后用leave 离开定义的loop标签
    loop_label:loop
    if xxx then 
    leave loop_label;
    end if;
    end loop;
    
    ITERATE 类型C中的continue;
    create procedure error()
    begin
    declare exit handler for 1216//如果发生1216错误,就执行插入error_tab
    insert into  error_tab (xxx);
    end;
    
  • 相关阅读:
    html转义
    mongodb 数据库 基础使用
    xpath基本语法
    HTTP
    JavaScript笔记6-数组新方法
    JavaScript笔记5-事件
    JavaScript笔记3--标识符和保留字
    JavaScript笔记4-数组
    jquery笔记1--选择器
    JavaScript笔记2
  • 原文地址:https://www.cnblogs.com/lisq/p/8386998.html
Copyright © 2011-2022 走看看