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;












  • 相关阅读:
    Platform创建WinCE内核时的编译错误
    evc4下载
    WinCE NK.bin与NK.nb0
    怎样安装SQL Server CE
    WinCE 5.0 & its eboot
    WinCE 5.0边做边学(4)
    nema协议解析
    wince romfs的一点讨论
    学习VC++时经常会遇到链接错误LNK2001
    wince 来电防火墙静音实现的几种办法
  • 原文地址:https://www.cnblogs.com/holly8/p/5636923.html
Copyright © 2011-2022 走看看