gpt4 book ai didi

sql - PL SQL如何选择所有列

转载 作者:搜寻专家 更新时间:2023-10-30 21:53:49 26 4
gpt4 key购买 nike

如何使以下包装器选择所有列“*”而不仅仅是 if_typenumber_infected

--spec
create or replace package WrapperSample is

type TResultRow is record(
if_type codes.cd%type
,number_infected Integer);

type TResultRowList is table of TResultRow;

function GetADedIcWarningsProv
(
p_hos_id in work_entity_data.hos_id%type
,p_date in date
) return TResultRowList
pipelined;

end WrapperSample;
/

--body
create or replace package body WrapperSample is

function GetADedIcWarningsProv
(
p_hos_id in work_entity_data.hos_id%type
,p_date in date
) return TResultRowList
pipelined is
v_refcur eOdatatypes_package.eOrefcur;
currentRow TResultRow;
begin
v_refcur := YourSchema.getADedIcWarningsProv(p_hos_id, p_date);

loop
fetch v_refcur
INTO currentRow;
exit when v_refcur%NotFound;
pipe row(currentRow);
end loop;

close v_refcur;

return;
end;

end WrapperSample;
/

最佳答案

我不确定我是否理解你的问题和要求。

但如果您正在寻找一种获取表格内容或其中一部分的方法,您可能会采用以下方法:

create table tq84_test_table (
col_1 number,
col_2 varchar2(10),
col_3 date
);

insert into tq84_test_table values (1, 'one' , sysdate);
insert into tq84_test_table values (2, 'two' , sysdate+1);
insert into tq84_test_table values (3, 'three', sysdate-1);


create or replace package tq84_sss as

type record_t is table of tq84_test_table%rowtype;

function GetADedIcWarningsProv return record_t;

end;
/

create or replace package body tq84_sss as

function GetADedIcWarningsProv return record_t
is
ret record_t;
begin

select * bulk collect into ret
from tq84_test_table;

return ret;

end GetADedIcWarningsProv;

end;
/

稍后您将像这样使用此函数:

declare

table_content tq84_sss.record_t;

begin

table_content := tq84_sss.GetADedIcWarningsProv;

for i in 1 .. table_content.count loop

dbms_output.put_line(table_content(i).col_1 || ' ' ||
table_content(i).col_2 || ' ' ||
table_content(i).col_3
);

end loop;

end;
/

关于sql - PL SQL如何选择所有列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4734279/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com