Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Oracle 编译过程时没有足够的值_Oracle_Stored Procedures_Collections_Package_Nested Table - Fatal编程技术网

Oracle 编译过程时没有足够的值

Oracle 编译过程时没有足够的值,oracle,stored-procedures,collections,package,nested-table,Oracle,Stored Procedures,Collections,Package,Nested Table,我正在尝试编译下面的程序,但是我没有得到足够的值。该计划将给出员工持有的前5个最高和最低工资 select * from all_tables where table_name like 'EMP5%'; create or replace package ptest1 is Type rec is record (emin number,salmin number,min_salary number,emax number,salmax number,max_salary number);

我正在尝试编译下面的程序,但是我没有得到足够的值。该计划将给出员工持有的前5个最高和最低工资

select * from all_tables where table_name like 'EMP5%';

create or replace package ptest1 is
Type rec is record (emin number,salmin number,min_salary number,emax number,salmax number,max_salary number);
TYPE T71 is table of rec;
procedure min_max(inp number, oup out T71);
end;
/

create or replace package body ptest1 as
procedure min_max(inp number, oup out T71)
as
begin
select emin,salmin,min_salary,emax,salmax,max_salary
into oup
from 
(select * from 
(select empno emin,sal salmin,row_number() over(order by sal asc) min_salary from emp5 where sal is not null) where min_salary <= inp ) t1,
(select * from 
(select empno emax,sal salmax,row_number() over(order by sal desc) max_salary from emp5 where sal is not null) where max_salary <= inp) t2
where t1.min_salary = t2.max_salary;
for i in oup.first..oup.last
loop
dbms_output.put_line('Employee number  '||oup(i).emin);
end loop;
end;
end ptest1;
/

假设您在发布时遗漏了批量收集行,则编译并运行该行;所以不确定你为什么会有问题-可能是你重新键入了整个东西,并意外地修复了它?我不确定逻辑是否符合你的要求。您需要一个过滤器,以限制为开始五行;但是为什么子查询和联接;为什么要使用PL/SQL呢?我需要根据输入显示前5名,要么是5,要么是其他数字,员工的最低和最高工资。我需要用批量收集打印好了,我知道你现在是如何使用imp的了。所以这就是你想要的,我想-除了你只打印emin,而不是emin和emax。无论如何,它不会抛出“值不够”错误,但我不知道您实际运行的代码中有什么不同。如果可能,请您创建一个将out参数作为collectionnested type的过程,该过程将返回员工的top n max和min salary。n是程序的输入,我仍然不明白。这就是你的程序已经做的。