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. webpack 打包css报错 Error: Chunk.entrypoints: Use Chunks.groupsIterable and filter by instanceof Entrypoint instead

    是webpack4和extract-text-webpack-plugin的兼容性问题 执行命令:npm install extract-text-webpack-plugin@next --save ...

  2. UESTC - 618

    #include<bits/stdc++.h> using namespace std; const int maxn = 1e6+11; const int N = 1e6; typed ...

  3. Oracle的pipelined函数实现高性能大数据处理

    从Oracle 8开始,我们就可以从一个collection类型的数据集合中查询出数据,这个集合称之为"虚拟表".它的方法是"SELECT FROM TABLE(CAST ...

  4. pandas强化练习

    这篇文章写得更好:http://wittyfans.com/coding/%E5%88%A9%E7%94%A8Pandas%E5%88%86%E6%9E%90%E7%BE%8E%E5%9B%BD%E4 ...

  5. linux中终端字体样式显示不正常

    问题:Centos终端中,字体显示不正常,中间感觉有空格,空格和单词傻傻分不清. 解决办法: yum groupinstall "Chinese Support" yum grou ...

  6. oracle 操作实例(一)----redolog 损坏恢复

    一,实验前的准备 数据库全备保证自己没成功还能补救一下 vim full.sh export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=$ORACL ...

  7. UNIX文件mode_t详解 ... S_IRUSR

    打开文件.新建文件和关闭文件操作 打开文件操作使用系统调用函数open(),该函数的作用是建立一个文件描述符,其他的函数可以通过文件描述符对指定文件进行读取与写入的操作.打开文件的一般形式是: ope ...

  8. (转)Linux 系统性能分析工具图解读(一、二)

    Linux 系统性能分析工具图解读(一.二) 原文:http://oilbeater.com/linux/2014/09/08/linux-performance-tools.html 最近看了 Br ...

  9. 重拾简单的linux指令之info 【转】

    info命令 可以利用该命令获取帮助 1. 语法格式:info <command> 2. 语法简述: 类似于man命令的获取帮助信息,比较于man命令更容易读.是以网页的结构来显示内容.而 ...

  10. java中创建User Libray

    第一步:右键项目==>Build Path ==>Configure Build Path... 第二步:选择Libraries==>点击 Add Library.. 第三步:选择U ...