PL SQL如何选择所有列 [英] PL SQL how to select all columns

查看:137
本文介绍了PL SQL如何选择所有列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使以下包装器选择所有列*而不是 if_type number_infected

How do i make the following wrapper select all columns "*" instead of just if_type, and 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;
/


推荐答案

请了解您的问题和要求。

I am not sure if I do understand your question and requirement.

但是,如果您正在寻找一种获取表格内容或其中一部分的方法,这可能是您如何处理:

But if you're looking for a way to get a table's content, or a portion thereof, this is probably how you would approach it:

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;
/

然后您可以使用此功能:

You would then later use this function like so:

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;
/

这篇关于PL SQL如何选择所有列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆