[英]How to give the result of a pipelined function as a default parameter?
我创建了这 4 种类型:
record type myrecord1 is (...)
record type myrecord2 is (...)
table tableofmyrecord1 is table of myrecord1;
table tableofmyrecord2 is table of myrecord2;
和2个功能:
function a(k in tableofmyrecord2) return packageName.tableofmyrecord1 PIPELINED;
function b return packageName.tableofmyrecord2 PIPELINED;
我可以有效地给出一个默认参数; null,表为空,我创建的表,但我可以直接给出流水线函数的结果。
function a return packageName.tOfmyrecord(k in tableofmyrecord2 :=package.b) PIPELINED
这不起作用。
此解决方案也不起作用。
declare
defaultArgOFA :=package.b;
function a return packageName.tOfmyrecord(k in tableofmyrecord2 :=defaultArgOFA) PIPELINED
同样的错误
PLS-00653: 不允许聚合/表函数
此错误表示您无法使用 PLSQL 调用流水线函数,因此您无法直接编写v:=a()
。 但是您可以使用 SQL。 下面是其中流水线的示例b
从流水线获取输入a
和乘法薪水。
包裹:
create or replace package pkg is
type tr is record (id int, name varchar2(10), sal int);
type tt is table of tr;
function a return tt pipelined;
function b(par in tt) return tt pipelined;
end pkg;
身体:
create or replace package body pkg is
function a return tt pipelined is
v_tr tr;
begin
v_tr.id := 1; v_tr.name := 'Mark'; v_tr.sal := 100;
pipe row (v_tr);
v_tr.id := 2; v_tr.name := 'Pete'; v_tr.sal := 120;
pipe row (v_tr);
return;
end;
function b(par in tt) return tt pipelined is
v_tr tr;
begin
for i in 1..par.last loop
v_tr := par(i);
v_tr.sal := v_tr.sal * 10;
pipe row (v_tr);
end loop;
return;
end;
end pkg;
这个测试对我有用:
select * from table(pkg.b(pkg.a));
结果:
ID NAME SAL
------ ---------- ----------
1 Mark 1000
2 Pete 1200
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.