返回一个 sys_refcursor 游标。
select
row_to_col_func('rowtocol_test','year,month','dept','expenditure',Aggregate_func => 'sum',colorder => 'dept',roworder => '1,2',when_value_null => '0')
from dual;
ROW_TO_COL_FUNC('ROWTOCOL_TEST
<Cursor>
YEAR MONTH 部门1 部门2 部门3
2009 1 50000 0 0
2009 2 50000 40000 25000
2009 3 0 25000 0
2010 1 35000 0 0
2010 2 0 0 60000
游标ROWTOCOL_TEST的值在 sqlplus可以看到。
我想能否直接返回一个table
用table函数提示,ORA-22905: 无法从非嵌套表项访问行。
如下:
select * from table( row_to_col_func('rowtocol_test','year,month','dept','expenditure',Aggregate_func => 'sum',colorder => 'dept',roworder => '1,2',when_value_null => '0')
);
望高手解答。