zoukankan      html  css  js  c++  java
  • 开发PL/SQL子程序——函数


    函数用于返回特定数据。如果应用程序经常需要执行sql语句返回特定数据,那么可以基于这些操作建立特定的函数。通过使用函数,不仅可以简化客户端应用程序的开发和维护,而且可以提高应用程序的执行性能。


    建立函数

    例子: 返回雇员工资的函数

    create or replace function get_sal (name in varchar2)
    return number as
    v_sal emp.sal%type;
    begin
    select sal into v_sal from emp ;where upper(ename)=upper(name);
    return v_sal;
    exceptionwhen no_data_found then
    raise_application_error(-20000,'雇员不存在');
    end;
    /
    var sal number 
    exec :sal:=get_sal('scott')
    print sal;

    删除函数

    drop function get_sal;

    显示函数代码

    select text from user_source where name='GET_SAL';

    -------------------------------------------

    作者:赵杰迪

    -------------------------------------------

  • 相关阅读:
    教你作一份高水准的简历
    python并发
    阻塞,非阻塞,同步,异步
    python三层架构
    paramiko与ssh
    python-进程
    生产者消费者模型
    python-线程
    python-socket
    python-mysql
  • 原文地址:https://www.cnblogs.com/zhaojiedi1992/p/oracle11g_sql_0020.html
Copyright © 2011-2022 走看看