FUNCTION:

  DEFINE:函数一般用于计算和返回一个值,可以将经常需要使用的计算或功能写成一个函数。

1.basic syntax

create [or replace] function fun_name [(parameter1[,parameter2])...] return data_type is|as

  [inner_variable]

begin

plsql_sentences;

[exception]

[dowith_sentences;]

end [fun_name];

2.Example Usage

  The sql query below is calculate average in the specify department.

create or replace function get_avg_pay(num_deptno number) return number is
num_avg_pay number;
begin
select avg(sal) into num_avg_pay from emp where deptno=num_deptno;
return(round(num_avg_pay,2));
excepton
when no_data_found then
dbms_output.put_line('This is departmetn not exists');
return(0);
end;
/
set serveroutput on
declare
avg_pay number;
begin
avg_pay:=get_avg_pay(10);
dbms_output.put_line('average wage is:'||avg_pay);
end;
/


 3.Delete Function

  BAISE SYNTAX:

select * from user_objects where object_type='FUNCTION';

drop functon fun_name;

ORACLE_FUNCTION的更多相关文章

  1. Oracle资源管理器(二)-- 创建和使用数据库资源计划

    (参考 http://blog.csdn.net/mrluoe/article/details/7969436 -- 整理并实践通过) 第1步,创建3个用户 SQL> create user s ...

  2. Oracle常用函数记录

    Oracle函数 --schema:hcf --不带任何参数 http://www.cnblogs.com/wuyisky/archive/2010/05/11/oracle_function.htm ...

随机推荐

  1. 误删除google浏览器用户,如何恢复之前收藏的标签,亲测有效

    第一种方案: 看 路径 C:\Users\admin\AppData\Local\Google\Chrome\User Data\Default  下或者 C:\Users\admin\AppData ...

  2. java单元测试之Mock静态方法

    1 public final class AmountUtil { public static String CustomFormatWith2Digits(int amount) { return ...

  3. 剪邮票--蓝桥杯--dfs--思路超清晰

    剪邮票 如[图1.jpg], 有12张连在一起的12生肖的邮票. 现在你要从中剪下5张来,要求必须是连着的. (仅仅连接一个角不算相连) 比如,[图2.jpg],[图3.jpg]中,粉红色所示部分就是 ...

  4. 【网络】CCNA实验一:Vlan、Trunk

    要求: 1:不同楼层物理隔离,但逻辑相连 2:相同楼层物理相连,但逻辑隔离 3:主机可以动态获取IP地址 4:不同VLAN间可以进行通信 5:主机最终访问www.esafenet.com弹出" ...

  5. html自定义垂直导航菜单(加强版--自定义传入menu参数,支持JSONArray、JSArray、JSONObject、JSObject)

    在上一篇中我简单写了个html自定义垂直导航菜单,缺点很明显,里面的数据是固定死的,不能动态更改数据. 这里我重写了一个修改版的垂直二级导航菜单,将原先的menuBox.init(config);修改 ...

  6. 2019.03.27 读书笔记 关于GC垃圾回收

    在介绍GC前,有必要对.net中CLR管理内存区域做简要介绍: 1. 堆栈:用于分配值类型实例.堆栈主要操作系统管理,而不受垃圾收集器的控制,当值类型实例所在方法结束时,其存储单位自动释放.栈的执行效 ...

  7. oracle 单实例DG(搭建篇一)

    一,介绍 lodding... 二,安装前环境配置 01,依赖包的安装: yum install binutils-* yum install compat-libstdc++-* yum insta ...

  8. 【Unity&独立游戏&音效】免费音效网站总览

    转载 http://blog.csdn.net/BuladeMian/article/details/70240868

  9. Python下Mysql数据连接池——单例

    # coding:utf-8 import threading import pymysql from DBUtils.PooledDB import PooledDB from app.common ...

  10. FileZilla的使用(包括Server和Client两个程序)

    1.安装 FileZillaServer和FileZillaClient,到官网去下载 https://filezilla-project.org/ 2.启动 FileZillaServer 它会提示 ...