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;












  • 相关阅读:
    Google TensorFlow 机器学习框架介绍和使用
    Linux下chkconfig命令详解转载
    wireshark----linux
    linux 开机自启转载
    linux 开机自启
    linux 开机自启脚本
    当进行make命令学习是出现error trying to exec 'cc1': execvp: No such file or directory
    centos6.4安装GCC
    安装cmake
    整型数转字符串
  • 原文地址:https://www.cnblogs.com/holly8/p/5636923.html
Copyright © 2011-2022 走看看