Plsql Oracle 19C数据库问题

Plsql Oracle 19C数据库问题,plsql,cursor,pipelined-function,oracle19c,Plsql,Cursor,Pipelined Function,Oracle19c,我有一个包在11g版本中运行良好 但是当我在19c版本中部署相同的包时,行为是不同的 PFB描述 包规范有一个游标,并使用游标%rowtype创建了一个表类型。 具有返回表类型的流水线函数 使用函数with table子句 select * from table(function) 因此,返回值可以作为一个表,我可以用列名读取结果 在11g中,函数返回的列标题与游标列名相同。 但在19c中,函数返回列标题,如“Attr_1、Attr_2等” 我需要函数返回列标题作为光标列名称 注意:代码非常敏

我有一个包在11g版本中运行良好

但是当我在19c版本中部署相同的包时,行为是不同的

PFB描述

包规范有一个游标,并使用游标%rowtype创建了一个表类型。 具有返回表类型的流水线函数

使用函数with table子句

select * from table(function)
因此,返回值可以作为一个表,我可以用列名读取结果

在11g中,函数返回的列标题与游标列名相同。 但在19c中,函数返回列标题,如“Attr_1、Attr_2等”

我需要函数返回列标题作为光标列名称

注意:代码非常敏感,无法共享

样本:
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”


请提供帮助。

解决您的问题的方法可能是:

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;
  • 能够重现被解释的行为。在19c上->属性1,属性2在11上->ID,说明

  • 我找到的解决方法是使用
    基表/视图%rowtype
    而不是
    游标%rowtype


  • 如果你不能分享真实的代码,那么请说明你的问题。PFB示例。我没有发现我的软件包规范和你的代码之间有任何区别。补充{为了区分。没有别的。对于我代码中存在的每个游标,我都无法正确创建视图。为什么行为在19C中发生了更改?有没有办法在新版本中恢复11g的行为?可能支持可以帮助您。也许如果您更改兼容性模式。Ask Tom的Connor McDonald通知我提出请求对Oracle团队来说,这是一个bug。