[英]How to give the result of a pipelined function as a default parameter?
I have created these 4 types :我创建了这 4 种类型:
record type myrecord1 is (...)
record type myrecord2 is (...)
table tableofmyrecord1 is table of myrecord1;
table tableofmyrecord2 is table of myrecord2;
and 2 functions :和2个功能:
function a(k in tableofmyrecord2) return packageName.tableofmyrecord1 PIPELINED;
function b return packageName.tableofmyrecord2 PIPELINED;
I can effectively give a default parameter ;我可以有效地给出一个默认参数; null, the table empty, a table that I have create, but I can give directly the result of a of pipelined function.
null,表为空,我创建的表,但我可以直接给出流水线函数的结果。
function a return packageName.tOfmyrecord(k in tableofmyrecord2 :=package.b) PIPELINED
This does'nt work.这不起作用。
This solution does'nt work too.此解决方案也不起作用。
declare
defaultArgOFA :=package.b;
function a return packageName.tOfmyrecord(k in tableofmyrecord2 :=defaultArgOFA) PIPELINED
same error同样的错误
PLS-00653: aggregate/table functions are not allowed
PLS-00653: 不允许聚合/表函数
This error says that you cannot call pipelined functions using PLSQL, so you can't directly write v:=a()
.此错误表示您无法使用 PLSQL 调用流水线函数,因此您无法直接编写
v:=a()
。 But you can use SQL.但是您可以使用 SQL。 Below is an example where pipelined
b
gets input from pipelined a
and multiplies salaries.下面是其中流水线的示例
b
从流水线获取输入a
和乘法薪水。
Package:包裹:
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;
Body:身体:
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;
And this test worked for me:这个测试对我有用:
select * from table(pkg.b(pkg.a));
Result:结果:
ID NAME SAL
------ ---------- ----------
1 Mark 1000
2 Pete 1200
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.