cod*_*441 1 sql database oracle plsql
如何使以下包装选择所有列"*"而不是只是if_type,和number_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;
/
Run Code Online (Sandbox Code Playgroud)
我不确定我是否理解你的问题和要求.
但是,如果您正在寻找获取表格内容或其中一部分内容的方法,这可能就是您接近它的方式:
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;
/
Run Code Online (Sandbox Code Playgroud)
之后你会像这样使用这个函数:
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;
/
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2020 次 |
| 最近记录: |