我有一个如下所述的设置
> create table earnings(earning_id number,
> col1 number,
> col2 number);
>
>create table trans(trans_id number,
> trans_attr1 number,
> trans_attr2 number);
>
>create or replace type trans_obj as object
> (trans_id number,
> trans_attr1 number,
> trans_attr2 number);
>
>create or replace type trans_coll as table of trans_obj;
>
>create or replace type earning_obj as object
> (
> earning_id number,
> col1 number,
> col2 number
> );
>
>create or replace type earnings_coll as table of earnings_obj;
>
>/
我有一个表格功能如下
函数计算(trans_t trans_coll)返回收益_coll流水线;
我想做类似下面的事情
>> function get_results(trans_t trans_coll)
>> return earnings_coll pipelined
>> as
>> l_earning_rec earnings_obj;
>>
>> begin
>>
>> for earning in (select * from table(calculate(trans_t)))
>> loop
>> l_earning_rec.extend();
>> // copy value from earning to l_earning_rec without having to copy each
>> // attribute individually
>>
>> pipe row(l_earning_rec);
>> end loop;
>>
>> return;
>> end get_results;
请让我知道是否有办法做到这一点。
此外,如果 get_results 是一个仅将记录插入收益表的过程,我该怎么做
insert into earnings
values (select * from table(calculate(trans_t)))
谢谢