zoukankan      html  css  js  c++  java
  • 存储函数

    存储函数与存储过程一样,是由SQL语句和过程式语句组成的代码片段.

    mysql-> use mysql_test;

    mysql-> delimiter$$

    mysql-> create function fn_search(cid int)

        -> returns char(20)

       -> deterministic  //提高where语句的性能的

      -> begin

      -> declare sex char(20);

      -> select cust_sex into sex from cust

      -> where cust_id=cid;

      -> if sex is null then

      -> return(select'没有该用户');

      -> else if sex='F' then

      -> return(select'女');

      -> else return(select'男');

      -> end if;

      -> end if;

    mysql-> select fn_search(902)$$ //调用存储函数

    mysql-> drop function if exists fn_search$$ //删除存储函数

     

    存储函数              存储过程
    不能拥有输出参数 可以拥有输出参数
    必须包含一条return语句 不允许包含return语句
    可以直接调用存储函数,不需要call语句 需要call语句调用存储过程
  • 相关阅读:
    前端面试题
    js collection
    javascript变量声明提升(hoisting)
    css3动画
    神奇的meta
    wap站bug小结
    前端collection
    js拾遗
    prototype之初印象
    自定义scrollBottom的值
  • 原文地址:https://www.cnblogs.com/lsxsx/p/13392617.html
Copyright © 2011-2022 走看看