oracle数据库sql语句11 函数
来源:互联网 发布:蔡司三坐标测量机编程软件教程 编辑:程序博客网 时间:2024/06/06 18:17
--函数
set serveroutput on;
--显示错误
show error;
--根据部门编号,输出该部门最大的工资
create or replace function fun_maxsal(dno in emp.deptno%type)
return emp.sal%type
as
maxsal emp.sal%type;
begin
select max(sal) into maxsal from emp where deptno=dno;
return maxsal;
end;
/
--执行
select * from emp where sal < fun_maxsal(10);
--根据部门编号,返回部门平均工资 ,参数返回最高工资,最低工资,
create or replace function fun_sal(dno in emp.deptno%type, maxsal out emp.sal%type, minsal out emp.sal%type)
return emp.sal%type
as
avgsal emp.sal%type;
begin
select max(sal),min(sal),avg(sal) into maxsal, minsal, avgsal from emp where deptno=dno;
return avgsal;
end;
/
--执行
declare
avgsal emp.sal%type;
maxsal emp.sal%type;
minsal emp.sal%type;
begin
avgsal:=fun_sal(10, maxsal, minsal);
dbms_output.put_line('avgsal:'||avgsal);
dbms_output.put_line('maxsal:'||maxsal);
dbms_output.put_line('minsal:'||minsal);
end;
/
set serveroutput on;
--显示错误
show error;
--根据部门编号,输出该部门最大的工资
create or replace function fun_maxsal(dno in emp.deptno%type)
return emp.sal%type
as
maxsal emp.sal%type;
begin
select max(sal) into maxsal from emp where deptno=dno;
return maxsal;
end;
/
--执行
select * from emp where sal < fun_maxsal(10);
--根据部门编号,返回部门平均工资 ,参数返回最高工资,最低工资,
create or replace function fun_sal(dno in emp.deptno%type, maxsal out emp.sal%type, minsal out emp.sal%type)
return emp.sal%type
as
avgsal emp.sal%type;
begin
select max(sal),min(sal),avg(sal) into maxsal, minsal, avgsal from emp where deptno=dno;
return avgsal;
end;
/
--执行
declare
avgsal emp.sal%type;
maxsal emp.sal%type;
minsal emp.sal%type;
begin
avgsal:=fun_sal(10, maxsal, minsal);
dbms_output.put_line('avgsal:'||avgsal);
dbms_output.put_line('maxsal:'||maxsal);
dbms_output.put_line('minsal:'||minsal);
end;
/
阅读全文
0 0
- oracle数据库sql语句11 函数
- Oracle数据库Sql语句详解---函数
- oracle数据库SQL语句
- oracle数据库sql语句
- Oracle数据库 SQL语句和单行字符串函数
- oracle数据库sql语句技巧
- Oracle数据库sql语句收藏
- Oracle 数据库监控SQL语句
- oracle数据库 sql语句应用
- Oracle 数据库常用Sql语句
- oracle数据库SQL语句详解
- Oracle数据库SQL语句大全
- oracle数据库sql语句优化
- oracle数据库的sql语句
- Oracle 数据库常用Sql语句
- Oracle数据库SQL语句学习
- Oracle数据库SQL常用语句
- oracle数据库常见SQL语句
- Django学习(三)模板定制
- 一段python 写自定义查看oracle current event 的小工具
- Mybatis反向生成DAO、Mapper、Model
- LeetCode-017 Letter Combinations of a Phone Number
- 对象数组和对象指针
- oracle数据库sql语句11 函数
- 文章标题
- 神级程序员纯css代码制作旋转闪光球体,css代码超两千行
- echarts使用总结
- BZOJ1975 [Sdoi2010]魔法猪学院 K短路 Astar A* 贪心
- 小红花问题(C++)
- oracle数据库sql语句12 包
- 使用DG4ODBC连接到Postgresql 数据库时报ORA-28500
- 1069. 微博转发抽奖(20)