ORACLE_FUNCTION
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的更多相关文章
- Oracle资源管理器(二)-- 创建和使用数据库资源计划
(参考 http://blog.csdn.net/mrluoe/article/details/7969436 -- 整理并实践通过) 第1步,创建3个用户 SQL> create user s ...
- Oracle常用函数记录
Oracle函数 --schema:hcf --不带任何参数 http://www.cnblogs.com/wuyisky/archive/2010/05/11/oracle_function.htm ...
随机推荐
- 小程序给scroll-view设置高度,使得它能适配各种尺寸的手机
scroll-view占满整个屏幕,且scroll-view的滚动不影响到页面其他地方的滚动 在iphone6的尺寸下,scroll-view设置高度为1110rpx,就不会影响页面其他地方的滚动 但 ...
- 1.nginx安装和配置
1.安装 1.1安装编译工具及库文件 yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel wget 1. ...
- 转 C#对多个集合和数组的操作(合并,去重,判断)
在开发过程中.数组和集合的处理是最让我们担心.一般会用for or foreach 来处理一些操作.这里介绍一些常用的集合跟数组的操作函数. 首先举例2个集合A,B. List<int> ...
- python 学习笔记一——Python安装和IDLE使用
好吧,一直准备学点啥,前些日子也下好了一些python电子书,但之后又没影了.年龄大了,就是不爱学习了.那就现在开始吧. 安装python 3 Mac OS X会预装python 2,Linux的大多 ...
- c语言3种方式实现参数传递
学习计算机已经两年了,参数传递已经成功恶心了我两年,今天在写二叉树遍历的时候成功对此忍无可忍.本文是在阅读https://blog.csdn.net/u013097971/article/detail ...
- MySQL 常用show 语句
1. show tables或show tables from database_name; -- 显示当前数据库中所有表的名称. 2. show databases; -- 显示mysql中所有数据 ...
- shell基础优化脚本
#!/bin/bash ######################################################### #Created Time: Tue Aug 7 01:29 ...
- django设置打印数据库日志
在settings.py中添加: LOGGING = { 'disable_existing_loggers': False, 'version': 1, 'handlers': { 'console ...
- (转)Nginx静态服务配置---详解root和alias指令
Nginx静态服务配置---详解root和alias指令 原文:https://www.jianshu.com/p/4be0d5882ec5 静态文件 Nginx以其高性能著称,常用与做前端反向代理服 ...
- innosetup的静默安装与卸载
静默安装,就是减少程序与用户的交互,一站式的安装过程(一气呵成) 1. 静默安装参数 innosetup的静默安装是通过参数来控制的 1.1. /silent ...