• PL/SQL编程—函数


    SQL> select * from mytest;
     
    ID    NAME                 PASSWD                                                                                         SALARY
    ----- -------------------- -------------------- --------------------------------------------------------------------------------
    1     gagaga               123                                                                                               100
    2     gaodingle!!!!        123                                                                                               100
    3     gagaga               123                                                                                               100
     
    SQL>
    SQL> create function annual_calsaly(id_in varchar2)
      2  return
      3  number is calsaly number(7,2);
      4  begin
      5  select salary*12 into calsaly from mytest where id =id_in;
      6  return calsaly;
      7  end;
      8  /
     
     
    Function created
     
    SQL> var abc number;
    SQL> call annual_calsaly('1')into:abc;
     
    Method called
    abc
    ---------
    1200
    函数必须要有返回值的在函数的开头
    return 返回类型 is 返回变量名 具体类型
    在begin操作完数据后在把对应的变量进行返回 return 返回变量名 
     
  • 相关阅读:
    2.4 学习总计 之 自己实现底部导航
    2.3 学习总结 之 分页查询
    2.2 学习总结 之 servlet 的两次抽取
    Rocket
    Rocket
    Rocket
    Rocket
    Rocket
    Rocket
    Rocket
  • 原文地址:https://www.cnblogs.com/lingyejun/p/7095721.html
Copyright © 2020-2023  润新知