开发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';
posted on 2013-05-02 12:20 LinuxPanda 阅读(263) 评论(0) 编辑 收藏 举报
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步