zoukankan      html  css  js  c++  java
  • 4、MySql的存储过程

    C:Program FilesMySQLMySQL Server 5.1in

    1.1 定义无参数的存储过程
    //定义语句结束用//
    delimiter //
    create procedure proc_teacher_noparam()
    begin
       select * from teacher;
    end
    //

    //定义语句结束用;
    delimiter ;

    1.2.调用无参数的存储过程
    call proc_teacher_noparam();


    2.1 定义输入参数的存储过程
    //定义语句结束用//
    delimiter //
    create procedure proc_teacher_inparam(in n int)
    begin
       select * from teacher where id=n;
    end
    //
    //定义语句结束用;
    delimiter ;

    2.2.调用输入参数的存储过程
    //定义变量
    set @n=1;

    //调用存储过程
    call proc_teacher_inparam(@n);


    3.1 定义有输出参数的存储过程
    drop procedure if exists proc_teacher_outparam;
    delimiter //
    create procedure proc_teacher_outparam(out n int)
    begin
       select count(*) into n from teacher;
    end
    //
    delimiter ;

    //3.2 调用输出参数的存储过程
    set @n=1;
    call proc_teacher_outparam(@n);
    select @n;

    //4.定义有输入和输出参数的存储过程
    delimiter //
    drop procedure if exists proc_teacher_in_outparam;
    create procedure proc_teacher_in_outparam(in n int,out o int)
    begin
       select count(*) into o from teacher where id=n;
    end
    //
    delimiter ;

    //4.2 调用带有输入和输出参数的存储过程
    sex @n=1;
    call proc_teacher_inoutparam(1,@n);
    select @n;

    //5.1 创建输入输出参数是同一个变量的存储过程
    delimiter //
    drop procedure if exists proc_teacher_inoutparam;
    create procedure proc_teacher_inoutparam(inout n int)
    begin
       select count(*) into n from teacher where id=n;
    end
    //

    delimiter ;

    //5.2 调用输入输出参数是同一个变量的存储过程
    sex @n=1;
    call proc_teacher_inoutparam(@n);
    select @n;












  • 相关阅读:
    mysql表分区
    .NET面试题
    .NET中CORS跨域访问WebApi
    一些VS2013的使用技巧(转载)
    java enum(枚举)使用详解 + 总结(转载)
    java枚举类型(转载)
    解析oracle的rownum,数据库查询结果返回行数设置
    使用jquery-qrcode生成二维码(转载)
    Spring 之注解事务 @Transactional(转载)
    spring @Transactional注解参数详解(转载)
  • 原文地址:https://www.cnblogs.com/holly8/p/5636923.html
Copyright © 2011-2022 走看看