我有一个在11g版本中工作正常的包。
但是当我在19c版本中部署相同的包时,行为是不同的。
PFB描述。
包规范有一个游标,并创建了一个游标为%rowtype的表类型。具有返回表类型的流水线函数。
使用function with table子句
select * from table(function)这样返回值就可以作为一个表,我可以用列名来读取结果。
在11g中,该函数返回与游标列名称相同的列标题。但在19c中,该函数返回的列标题类似于'Attr_1,Attr_2,etc‘。
我需要该函数以游标列名的形式返回列标题。
注意:代码不能共享,因为它非常敏感。
样本:对样本进行PFB。
Create table tb_test (id number, description varchar2 (50));
create or replace package pkg_test is
cursor cur_test is
select *
from tb_test
where 1=2;
type typ_cur_test is table of cur_test%rowtype;
function fn_test(p_rows in number) return typ_cur_test pipelined;
end;
create or replace package body pkg_test is
function fn_test(p_rows in number) return typ_cur_test pipelined as
l_tab typ_cur_test := cur_typ_test();
begin
for i in 1..p_rows loop l_tab.extend;
l_tab(i).Id := i;
l_tab(i). Description := 'test';
pipe roe(l_tab(i));
end loop;
return ;
end;
end pkg_test;
Select * from table(pkg_test.fn_test(2));在11g中,上面的select给出的列标题是"id,description",但在19c中,我得到的是"ATTR_1,ATTR_2“。
请帮帮忙。
发布于 2020-02-14 21:22:13
您问题的解决方案可能是:
create or replace package pkg_test is
cursor cur_test is
select *
from tb_test
where 1=2;
type typ_cur_test is table of {tb_test}%rowtype;
function fn_test(p_rows in number) return typ_cur_test pipelined;
end;base table/view%rowtype而不是cursor%rowtype.https://stackoverflow.com/questions/60225275
复制相似问题