• 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;
    
  • 相关阅读:
    winform 与 html 交互 简单案例
    Winform窗口弹出位置控制
    c#预处理指令
    最简单的数据绑定
    Asp.Net细节性问题精萃
    AjaxUploader使用
    Log4net对文件的支持
    Log4net对数据库的支持
    Log4net使用
    Log4net介绍
  • 原文地址:https://www.cnblogs.com/lisq/p/8386998.html
Copyright © 2020-2023  润新知