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;












  • 相关阅读:
    野指针
    MFC动态创建控件及其消息响应函数
    关于CString总结
    关于char, wchar_t, TCHAR, _T(),L,宏 _T、TEXT,_TEXT、L
    VS2005、VS2008中的快捷键、组合键大全
    could not be found (are you missing a using directive or an assembly reference?)
    项目任务管理系统
    VSDBCMD
    sqlcmd
    Microsoft® Command Line Utilities 11 for SQL Server®
  • 原文地址:https://www.cnblogs.com/holly8/p/5636923.html
Copyright © 2011-2022 走看看